andig / carddav2fb

Download CardDAV VCards and upload as phonebook to AVM FRITZ!Box
63 stars 19 forks source link

Download phonebook: namespace error #214

Closed blacksenator closed 4 years ago

blacksenator commented 4 years ago

https://github.com/andig/carddav2fb/blob/f38695496830e79d6f00bea0de8c3a658f83469d/src/functions.php#L558 causes an error:

Namespace prefix xsi for type on ... is not defined ...

If contacts have been successfully uploaded using the SetPhonebookEntry SOAP function.

The FRITZ!Box xml will e.g. looks like this (first entry is added via SOAP/TR-064, the second and following entries are added via GUI):

<?xml version="1.0" encoding="utf-8"?>
<phonebooks>
    <phonebook name="XXXXXXXXXXXXXXXXX" owner="1">
        <contact xsi:type="SOAP-ENC:Struct">
            <category xsi:type="xsd:string">0</category>
            <person xsi:type="SOAP-ENC:Struct">
                <realName xsi:type="xsd:string">XXXXXXXXXXXXXXXXX</realName>
            </person>
            <telephony xsi:type="SOAP-ENC:Struct" nid="1">
                <@attributes xsi:type="ns2:Map">
                    <item>
                        <key xsi:type="xsd:string">nid</key>
                        <value xsi:type="xsd:string">1</value>
                    </item>
                </@attributes>
                <number xsi:type="xsd:string" prio="1" id="0">XXXXXXXXXXXXXXXXX</number>
            </telephony>
            <services xsi:type="SOAP-ENC:Struct" />
            <setup xsi:type="SOAP-ENC:Struct" />
            <features xsi:type="SOAP-ENC:Struct">
                <@attributes xsi:type="ns2:Map">
                    <item>
                        <key xsi:type="xsd:string">doorphone</key>
                        <value xsi:type="xsd:string">0</value>
                    </item>
                </@attributes>
            </features>
            <mod_time xsi:type="xsd:string">1593261627</mod_time>
            <uniqueid>2226885</uniqueid>
        </contact>
        <contact>
            <category>0</category>
            <person>
                <realName>XXXXXXXXXXXXXXXXX</realName>
            </person>
            <telephony nid="1">
                <number type="other" prio="1" id="0">XXXXXXXXXXXXXXXXX</number>
            </telephony>
            <services />
            <setup />
            <features doorphone="0" />
            <mod_time>1452420868</mod_time>
            <uniqueid>2215332</uniqueid>
        </contact>
...

If I understand it correctly, it is actually a mistake on the part of AVM/FRITZ!OS that the namespaces are not declared, although some contact nodes require them. Can the error be compensated as long as there is no correction by AVM?

andig commented 4 years ago

Wann/wobei entsteht der Fehler?

blacksenator commented 4 years ago

Der Fehler entsteht hier $xmlPhonebook = simplexml_load_string($result);

Die Ursache ist, dass ein User in ein Telefonbuch per SOAP-Funktion einen Kontakt hinzufügt.

andig commented 4 years ago

Man könnte das mit regex vorbehandeln, schön wäre aber erstmal xsi zu verstehen. Fehlt da evtl schon ein Teil des XMLs? Ansonsten wär‘s egtl. ein Bug bei AVM die ja auch oft gelöst werden.

blacksenator commented 4 years ago

Fehler lag nicht bei AVM, sondern beim Programm von mir: ich habe an die SOAP-funktion ein SimpleXMLElement übergeben an Stelle eines XML als String