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

bugfix: corrected XML parsing error #809

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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