Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve parsing of broken XML on responses by ignoring namespaces #224

Merged
merged 6 commits into from
Mar 29, 2024

Conversation

StevenLooman
Copy link
Owner

@StevenLooman StevenLooman commented Mar 22, 2024

Improve parsing of broken XML on responses by ignoring namespaces

Fixes #221

Copy link

codecov bot commented Mar 25, 2024

Codecov Report

Attention: Patch coverage is 78.46154% with 14 lines in your changes are missing coverage. Please review.

Project coverage is 72.56%. Comparing base (55121ed) to head (3952276).

Files Patch % Lines
async_upnp_client/client.py 78.46% 14 Missing ⚠️
Additional details and impacted files
@@               Coverage Diff               @@
##           development     #224      +/-   ##
===============================================
+ Coverage        72.46%   72.56%   +0.10%     
===============================================
  Files               19       19              
  Lines             4049     4093      +44     
===============================================
+ Hits              2934     2970      +36     
- Misses            1115     1123       +8     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@StevenLooman
Copy link
Owner Author

Can you test if this works for you, @brostosjoined?

@brostosjoined
Copy link
Contributor

Discoveries: {{'CACHE-CONTROL': 'max-age=1800', 'DATE': 'Tue, 26 Mar 2024 06:49:03 GMT', 'EXT': '', 'LOCATION': 'http://192.168.100.1:49652/49652gatedesc.xml', 'OPT': '"http://schemas.upnp.org/upnp/1/0/"; ns=01', '01-NLS': 'cf2f9c7c-732d-11be-aad3-96b10c8ac404', 'SERVER': 'Linux/4.4.240, UPnP/1.0, Portable SDK for UPnP devices/1.12.1', 'X-User-Agent': 'UPnP/1.0 DLNADOC/1.50', 'ST': 'urn:schemas-upnp-org:device:InternetGatewayDevice:1', 'USN': 'uuid:00e0fc37-2525-2828-2500-58AEA862CCCB::urn:schemas-upnp-org:device:InternetGatewayDevice:1', '_host': '192.168.100.1', '_udn': 'uuid:00e0fc37-2525-2828-2500-58AEA862CCCB', '_location_original': 'http://192.168.100.1:49652/49652gatedesc.xml', 'location': 'http://192.168.100.1:49652/49652gatedesc.xml', '_timestamp': datetime.datetime(2024, 3, 26, 9, 49, 1, 880942), '_remote_addr': ('192.168.100.1', 46598), '_port': 46598, '_local_addr': ('0.0.0.0', 63359), '_source': <SsdpSource.SEARCH: 'search'>}}
Using device at location: http://192.168.100.1:49652/49652gatedesc.xml
Creating port mapping
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><s:Body>
<u:GetExternalIPAddressResponse xmlns:u="urn:schemas-upnp-org:service:WANIPConnection:1">
<NewExternalIPAddress>100.65.26.64</NewExternalIPAddress>
</u:GetExternalIPAddressResponse>
</s:Body> </s:Envelope>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><s:Body>
<u:AddPortMappingResponse xmlns:u="urn:schemas-upnp-org:service:WANIPConnection:1"></u:AddPortMappingResponse>
</s:Body> </s:Envelope>
Deleting port mapping
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><s:Body>
<u:GetExternalIPAddressResponse xmlns:u="urn:schemas-upnp-org:service:WANIPConnection:1">
<NewExternalIPAddress>100.65.26.64</NewExternalIPAddress>
</u:GetExternalIPAddressResponse>
</s:Body> </s:Envelope>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><s:Body>
<u:DeletePortMappingResponse xmlns:u0="urn:schemas-upnp-org:service:WANIPConnection:1"></u:DeletePortMappingResponse>
</s:Body> </s:Envelope>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><s:Body>
<u:DeletePortMappingResponse xmlns:u="urn:schemas-upnp-org:service:WANIPConnection:1"></u:DeletePortMappingResponse>
</s:Body> </s:Envelope>

👍

@brostosjoined
Copy link
Contributor

let me try it using the non_strict=False

@StevenLooman
Copy link
Owner Author

let me try it using the non_strict=False

Great, thanks!

@brostosjoined
Copy link
Contributor

brostosjoined commented Mar 29, 2024

Yeah its working perfectly

@StevenLooman
Copy link
Owner Author

Great, thank you for testing. I'll create a new release somewhere this weekend.

@StevenLooman
Copy link
Owner Author

I've tested a bit more with Home Assistant and did not see any errors. I'll release a new version. I'll also create a Home Assistant PR to bump the version as well, though I don't think you're interested in this.

@StevenLooman StevenLooman merged commit e6d464f into development Mar 29, 2024
16 checks passed
@StevenLooman StevenLooman deleted the fix_221 branch March 29, 2024 15:49
@brostosjoined
Copy link
Contributor

Count me out on that but ill still be taking a look at the project.

@brostosjoined
Copy link
Contributor

Discoveries: {{'CACHE-CONTROL': 'max-age=1800', 'DATE': 'Thu, 01 Jan 1981 21:40:53 GMT', 'EXT': '', 'LOCATION': 'http://192.168.100.1:49652/49652gatedesc.xml', 'OPT': '"http://schemas.upnp.org/upnp/1/0/"; ns=01', '01-NLS': '9f8f6628-1dd1-11b2-9b6c-9cbb8849d28c', 'SERVER': 'Linux/3.10.53-HULK2, UPnP/1.0, Portable SDK for UPnP devices/1.6.18', 'X-User-Agent': 'UPnP/1.0 DLNADOC/1.50', 'ST': 'urn:schemas-upnp-org:device:InternetGatewayDevice:1', 'USN': 'uuid:00e0fc37-2525-2828-2500-A0A33BAE4E09::urn:schemas-upnp-org:device:InternetGatewayDevice:1', '_host': '192.168.100.1', '_udn': 'uuid:00e0fc37-2525-2828-2500-A0A33BAE4E09', '_location_original': 'http://192.168.100.1:49652/49652gatedesc.xml', 'location': 'http://192.168.100.1:49652/49652gatedesc.xml', '_timestamp': datetime.datetime(2024, 4, 29, 13, 12, 25, 239614), '_remote_addr': ('192.168.100.1', 56143), '_port': 56143, '_local_addr': ('0.0.0.0', 51398), '_source': <SsdpSource.SEARCH: 'search'>}}
Using device at location: http://192.168.100.1:49652/49652gatedesc.xml
Creating port mapping
Deleting port mapping

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Parse Error on deleting port mapping
2 participants