aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--wee_slack.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/wee_slack.py b/wee_slack.py
index 4a69025..0824268 100644
--- a/wee_slack.py
+++ b/wee_slack.py
@@ -4750,9 +4750,9 @@ def unfurl_rich_text_section(block):
def unfurl_block_element(element):
if element["type"] == "mrkdwn":
- return render_formatting(element["text"])
+ return htmlescape(render_formatting(element["text"]))
elif element["type"] in ["text", "plain_text"]:
- return element["text"]
+ return htmlescape(element["text"])
elif element["type"] == "image":
if element.get("alt_text"):
return "{} ({})".format(element["image_url"], element["alt_text"])
@@ -4832,6 +4832,10 @@ def unfurl_refs(text):
return re.sub(r"<([^|>]*)(?:\|([^>]*))?>", unfurl_ref, text)
+def htmlescape(text):
+ return text.replace("&", "&amp;").replace("<", "&lt;").replace(">", "&gt;")
+
+
def unhtmlescape(text):
return text.replace("&lt;", "<").replace("&gt;", ">").replace("&amp;", "&")