From 867d6134f9ef0d66deb5f5b4da63d5d5a538810a Mon Sep 17 00:00:00 2001 From: Trygve Aaberge Date: Sat, 14 Oct 2017 10:03:50 +0200 Subject: 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. --- wee_slack.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'wee_slack.py') 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) -- cgit