diff --git a/aioupnp/constants.py b/aioupnp/constants.py index 63e40ed..333023b 100644 --- a/aioupnp/constants.py +++ b/aioupnp/constants.py @@ -2,6 +2,7 @@ POST = "POST" ROOT = "root" SPEC_VERSION = "specVersion" XML_VERSION = "" +XML_VERSION_PREFIX = "(\s*.)*|\>)" + "(\<\?xml version=\"1\.0\"[^>]*\?\>(\s*.)*|\>)" ) XML_ROOT_SANITY_PATTERN = re.compile( @@ -38,7 +38,7 @@ def serialize_scpd_get(path: str, address: str) -> bytes: def deserialize_scpd_get_response(content: bytes) -> Dict[str, Any]: - if XML_VERSION.encode() in content: + if XML_VERSION_PREFIX.encode() in content: parsed: List[Tuple[bytes, bytes]] = CONTENT_PATTERN.findall(content.decode()) xml_dict = xml_to_dict('' if not parsed else parsed[0][0]) return parse_device_dict(xml_dict)