kbr / fritzconnection

Python-Tool to communicate with the AVM Fritz!Box by the TR-064 protocol and the AHA-HTTP-Interface
MIT License
304 stars 59 forks source link

Envelope builder glues xml attributes together #60

Closed bufemc closed 3 years ago

bufemc commented 3 years ago

As mentioned in previous issue, but this should go in an extra ticket, e.g. so we can solve it with a PR:

When debugging I get this for building the envelope: there is really no space between s:encodingStyle and the followed xmlns:s

s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"

<?xml version="1.0" encoding="utf-8"?><s:Envelope s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Body><u:GetPhonebook xmlns:u="urn:dslforum-org:service:X_AVM-DE_OnTel:1"><s:NewPhonebookId>0</s:NewPhonebookId></u:GetPhonebook></s:Body></s:Envelope>

The even more strange thing is, AVM Fritzbox does not care and will still process it, although it's TBH invalid XML!

So, what's the culprit?:

soaper.py L124:

    envelope = re.sub(r'\s +', '', """
        <?xml version="1.0" encoding="utf-8"?>
        <s:Envelope s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
                    xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">{body}
        </s:Envelope>
        """)

the re.sub expression glues both together. If you instead write it side by side, with a space between, it will not glue, but be over the 80 columns of course .)

kbr commented 3 years ago

Seems to be not a problem with the fritz parser. However I will fix this. Thanks for reporting.

kbr commented 3 years ago

Fixed with 1.3.3