aboutsummaryrefslogtreecommitdiffstats
path: root/wee_slack.py
diff options
context:
space:
mode:
authorTrygve Aaberge <trygveaa@gmail.com>2017-08-01 15:25:25 +0200
committerTrygve Aaberge <trygveaa@gmail.com>2017-08-01 15:57:54 +0200
commit40c937f894d2968774dab41ddff02fd6a8c0dd5f (patch)
tree41258138c0073f5d702c6abf1b3a557eba44e1eb /wee_slack.py
parent2b3b969dffcaee7d2dfe23d4bcedf57c685567dc (diff)
downloadwee-slack-40c937f894d2968774dab41ddff02fd6a8c0dd5f.tar.gz
Fix HTML entity-encoding of outgoing messages
We have to replace the & before we replace < and >, otherwise the & in &lt; and &gt; are going to be replaced. Additionally, we need to end the sequences with ; which was missing.
Diffstat (limited to 'wee_slack.py')
-rw-r--r--wee_slack.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/wee_slack.py b/wee_slack.py
index 680ff6b..019ba5f 100644
--- a/wee_slack.py
+++ b/wee_slack.py
@@ -2541,11 +2541,11 @@ def linkify_text(message, team, channel):
.replace('\x1D', '_')
.replace('\x1F', config.map_underline_to)
# Escape chars that have special meaning to Slack. Note that we do not
- # (and should not) perform a full URL escaping here.
+ # (and should not) perform full HTML entity-encoding here.
# See https://api.slack.com/docs/message-formatting for details.
- .replace('<', '&lt')
- .replace('>', '&gt')
- .replace('&', '&amp')
+ .replace('&', '&amp;')
+ .replace('<', '&lt;')
+ .replace('>', '&gt;')
.split(' '))
for item in enumerate(message):
targets = re.match('^\s*([@#])([\w.-]+[\w. -])(\W*)', item[1])