From 72fd95bcc543f22eaa399a1d1a5c46c63e62c9db Mon Sep 17 00:00:00 2001 From: Jack Robison Date: Wed, 13 Nov 2019 10:57:12 -0500 Subject: [PATCH 1/3] fix soap xml parsing for tp-link devices --- aioupnp/serialization/soap.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aioupnp/serialization/soap.py b/aioupnp/serialization/soap.py index 9ee2c08..e212e79 100644 --- a/aioupnp/serialization/soap.py +++ b/aioupnp/serialization/soap.py @@ -7,7 +7,7 @@ from aioupnp.constants import XML_VERSION, ENVELOPE, BODY, FAULT, CONTROL from aioupnp.serialization.xml import xml_to_dict CONTENT_NO_XML_VERSION_PATTERN = re.compile( - "(\)".encode() + b"(\<([^:>]*)\:Envelope xmlns\:[^:>]*=\"http\:\/\/schemas\.xmlsoap\.org\/soap\/envelope\/\"(\s*.)*\>)" ) -- 2.45.3 From 2e24b3546330a71b0b3e1ddd664a0d7055349c08 Mon Sep 17 00:00:00 2001 From: Jack Robison Date: Thu, 14 Nov 2019 13:35:03 -0500 Subject: [PATCH 2/3] test tp-link xml namespace parsing bug --- tests/serialization/test_soap.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/serialization/test_soap.py b/tests/serialization/test_soap.py index 8193453..fe06911 100644 --- a/tests/serialization/test_soap.py +++ b/tests/serialization/test_soap.py @@ -114,3 +114,11 @@ class TestSOAPSerialization(unittest.TestCase): raised = True self.assertEqual(str(err), expected) self.assertTrue(raised) + + def test_soap_env_namespace_response(self): + # tp link devices use `SOAP-ENV` namespace rather than the normal `s` + response = b'HTTP/1.1 200 OK\r\nCONNECTION: close\r\nSERVER: ipos/7.0 UPnP/1.0 TL-WR940N/TL-WR941ND/3.0\r\nCONTENT-LENGTH: 404\r\nCONTENT-TYPE: text/xml; charset="utf-8"\r\n\r\n\n\n\n100.100.100.100\n\n' + self.assertDictEqual( + deserialize_soap_post_response(response, 'GetExternalIPAddress', self.st.decode()), + {'NewExternalIPAddress': '100.100.100.100'} + ) -- 2.45.3 From 1570f4a2382387a00662eeed8b6d8da815899ef9 Mon Sep 17 00:00:00 2001 From: Jack Robison Date: Thu, 14 Nov 2019 13:36:20 -0500 Subject: [PATCH 3/3] delete empty file --- tests/generate_test.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 tests/generate_test.py diff --git a/tests/generate_test.py b/tests/generate_test.py deleted file mode 100644 index e69de29..0000000 -- 2.45.3