From 60e1b9dd76a61d568ab523004990667367eca50d Mon Sep 17 00:00:00 2001 From: 42kun Date: Tue, 24 Oct 2023 11:50:55 +0800 Subject: [PATCH] bugfix: corrected XML parsing error --- werobot/parser.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/werobot/parser.py b/werobot/parser.py index 23720f90..0cb0677b 100644 --- a/werobot/parser.py +++ b/werobot/parser.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- +import re import xmltodict from werobot.messages.messages import MessageMetaClass, UnknownMessage from werobot.messages.events import EventMetaClass, UnknownEvent @@ -11,7 +12,8 @@ def parse_user_msg(xml): def parse_xml(text): - xml_dict = xmltodict.parse(text)["xml"] + text_clean = re.sub(b'[\x00-\x1F]', b'', text) + xml_dict = xmltodict.parse(text_clean)["xml"] xml_dict["raw"] = text return xml_dict