Skip to content

Commit

Permalink
bugfix: corrected XML parsing error
Browse files Browse the repository at this point in the history
  • Loading branch information
kunpengGK committed Nov 28, 2023
1 parent c7b6c57 commit fc1715b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

from setuptools import setup, find_packages
from setuptools.command.test import test as TestCommand
import sys


class PyTest(TestCommand):
Expand Down
4 changes: 2 additions & 2 deletions werobot/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class Client(object):
微信 API 操作类
通过这个类可以方便的通过微信 API 进行一系列操作,比如主动发送消息、创建自定义菜单等
"""

def __init__(self, config):
self.config = config
self._token = None
Expand Down Expand Up @@ -357,8 +358,7 @@ def upload_custom_service_account_avatar(self, account, avatar):
:return: 返回的 JSON 数据包
"""
return self.post(
url=
"http://api.weixin.qq.com/customservice/kfaccount/uploadheadimg",
url="http://api.weixin.qq.com/customservice/kfaccount/uploadheadimg",
params={
"access_token": self.token,
"kf_account": account
Expand Down
4 changes: 3 additions & 1 deletion werobot/parser.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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-\x09\x0B-\x0C\x0E-\x1F]', b'', text)
xml_dict = xmltodict.parse(text_clean)["xml"]
xml_dict["raw"] = text
return xml_dict

Expand Down

0 comments on commit fc1715b

Please sign in to comment.