diff options
author | Trygve Aaberge <trygveaa@gmail.com> | 2017-10-14 10:03:50 +0200 |
---|---|---|
committer | Trygve Aaberge <trygveaa@gmail.com> | 2017-10-15 22:05:55 +0200 |
commit | 867d6134f9ef0d66deb5f5b4da63d5d5a538810a (patch) | |
tree | fc3be80464694471e2115cc3ab1df8b178bed56b /wee_slack.py | |
parent | db6b99fc17a1e37564723452963246a9e7a2b787 (diff) | |
download | wee-slack-867d6134f9ef0d66deb5f5b4da63d5d5a538810a.tar.gz |
fix: Unescape html before checking attachment links
The title and from_url fields of attachments doesn't seem to be escaped,
so the check if they already are in the text didn't work if the link
contained e.g. an ampersand.
Diffstat (limited to 'wee_slack.py')
-rw-r--r-- | wee_slack.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/wee_slack.py b/wee_slack.py index 334a8ba..9e9202c 100644 --- a/wee_slack.py +++ b/wee_slack.py @@ -2600,6 +2600,7 @@ def unhtmlescape(text): def unwrap_attachments(message_json, text_before): + text_before_unescaped = unhtmlescape(text_before) attachment_texts = [] a = message_json.get("attachments", None) if a: @@ -2620,7 +2621,7 @@ def unwrap_attachments(message_json, text_before): t.append(attachment['pretext']) title = attachment.get('title', None) title_link = attachment.get('title_link', '') - if title_link in text_before: + if title_link in text_before_unescaped: title_link = '' if title and title_link: t.append('%s%s (%s)' % (prepend_title_text, title, title_link,)) @@ -2629,7 +2630,7 @@ def unwrap_attachments(message_json, text_before): t.append('%s%s' % (prepend_title_text, title,)) prepend_title_text = '' from_url = attachment.get('from_url', '') - if from_url not in text_before and from_url != title_link: + if from_url not in text_before_unescaped and from_url != title_link: t.append(from_url) atext = attachment.get("text", None) |