diff options
author | John Smith <mrdoctorwho@gmail.com> | 2018-12-25 07:26:47 +0300 |
---|---|---|
committer | John Smith <mrdoctorwho@gmail.com> | 2018-12-25 07:26:47 +0300 |
commit | 9b76046e98efea59440f9a1a2cfd4d080d0785cf (patch) | |
tree | 4bf894cb2d26b4426af891b18217c480ea17bae2 /extensions | |
parent | 9f56f835c706254b242bf8aee8ca6a028c170e40 (diff) |
fix documents not being attached due to unicode magic
Diffstat (limited to 'extensions')
-rw-r--r-- | extensions/attachments.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/extensions/attachments.py b/extensions/attachments.py index af3bed5..009aac6 100644 --- a/extensions/attachments.py +++ b/extensions/attachments.py @@ -12,7 +12,8 @@ WALL_COMMENT_LINK = "https://vk.com/wall%(owner_id)s_%(post_id)s?w=wall%(owner_i PHOTO_SIZES = ("src_xxxbig", "src_xxbig", "src_xbig", "src_big", "src", "url", "src_small") STICKER_SIZES = ("photo_256", "photo_128", "photo_64") -ATTACHMENT_REGEX = re.compile(r"^(Photo|Document|Sticker)\:\s(“.+?”\s—\s)?(?P<url>http[s]?:\/\/(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+$)") +ATTACHMENT_REGEX = re.compile(r"^(Photo|Document|Sticker)\:\s(“.+?”\s—\s)?"\ + r"(?P<url>http[s]?:\/\/(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+$)", re.UNICODE) GLOBAL_USER_SETTINGS["parse_wall"] = {"value": 0, "label": "Parse wall attachments"} GLOBAL_USER_SETTINGS["make_oob"] = {"value": 0, "label": "Allow OOB for attachments", @@ -121,7 +122,7 @@ def attachments_msg03(msg, destination, source): else: user = Users.get(destination) if user and user.settings.make_oob: - match = ATTACHMENT_REGEX.match(body) + match = ATTACHMENT_REGEX.match(body.encode("utf-8")) if match: link = match.group("url") url = msg.setTag("x", namespace=xmpp.NS_OOB) |