aboutsummaryrefslogtreecommitdiffstats
path: root/wee_slack.py
diff options
context:
space:
mode:
authorTollef Fog Heen <tfheen@err.no>2017-07-28 22:24:49 +0200
committerTollef Fog Heen <tfheen@err.no>2017-07-28 22:24:49 +0200
commit625580b3432f3895cd60ae7ce990280427eb728b (patch)
tree0dc353428e4a7278a4fb0e28b08fc04cf269a2e1 /wee_slack.py
parentdafa844de9e22167731c9daef95ffe9e7d1a5831 (diff)
downloadwee-slack-625580b3432f3895cd60ae7ce990280427eb728b.tar.gz
Decode the basic HTML entities in topic handling
Closes: #315
Diffstat (limited to 'wee_slack.py')
-rw-r--r--wee_slack.py15
1 files changed, 9 insertions, 6 deletions
diff --git a/wee_slack.py b/wee_slack.py
index a8fb945..a89d675 100644
--- a/wee_slack.py
+++ b/wee_slack.py
@@ -2335,9 +2335,9 @@ def subprocess_message_deleted(message_json, eventrouter, channel, team):
def subprocess_channel_topic(message_json, eventrouter, channel, team):
- text = unfurl_refs(message_json["text"], ignore_alt_text=False)
+ text = unhtmlescape(unfurl_refs(message_json["text"], ignore_alt_text=False))
channel.buffer_prnt(w.prefix("network").rstrip(), text, message_json["ts"], tagset="muted")
- channel.render_topic(message_json["topic"])
+ channel.render_topic(unhtmlescape(message_json["topic"]))
def process_reply(message_json, eventrouter, **kwargs):
@@ -2506,10 +2506,7 @@ def render(message_json, team, channel, force=False):
text += unfurl_refs(unwrap_attachments(message_json, text_before), ignore_alt_text=config.unfurl_ignore_alt_text)
text = text.lstrip()
- text = text.replace("\t", " ")
- text = text.replace("&lt;", "<")
- text = text.replace("&gt;", ">")
- text = text.replace("&amp;", "&")
+ text = unhtmlescape(text.replace("\t", " "))
if message_json.get('mrkdwn', True):
text = render_formatting(text)
@@ -2599,6 +2596,12 @@ def unfurl_ref(ref, ignore_alt_text=False):
return display_text
+def unhtmlescape(text):
+ return text.replace("&lt;", "<") \
+ .replace("&gt;", ">") \
+ .replace("&amp;", "&")
+
+
def unwrap_attachments(message_json, text_before):
attachment_text = ''
a = message_json.get("attachments", None)