From 15a853bd8a8f40521fd7fedf821c7c7b98037d45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C4=93teris=20Caune?= Date: Tue, 19 Feb 2019 11:11:29 +0200 Subject: [PATCH] Escape asterisks in Slack messages. Fixes #223 --- CHANGELOG.md | 1 + hc/front/templatetags/hc_extras.py | 7 +++++++ templates/integrations/slack_message.json | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c04c83fb..34af2094 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ All notable changes to this project will be documented in this file. ### Bug Fixes - Fix refreshing of the checks page filtered by tags (#221) +- Escape asterisks in Slack messages (#223) ## 1.5.0 - 2019-02-04 diff --git a/hc/front/templatetags/hc_extras.py b/hc/front/templatetags/hc_extras.py index d8306f84..c25182f5 100644 --- a/hc/front/templatetags/hc_extras.py +++ b/hc/front/templatetags/hc_extras.py @@ -114,3 +114,10 @@ def break_underscore(s): s = s.replace("_", "_\u200b") return s + + +@register.filter +def fix_asterisks(s): + """ Prepend asterisks with "Combining Grapheme Joiner" characters. """ + + return s.replace("*", "\u034f*") diff --git a/templates/integrations/slack_message.json b/templates/integrations/slack_message.json index 8983ec18..40338b3a 100644 --- a/templates/integrations/slack_message.json +++ b/templates/integrations/slack_message.json @@ -25,7 +25,7 @@ }, {% elif check.kind == "cron" %} {"title": "Schedule", - "value": "{{ check.schedule|escapejs }}", + "value": "{{ check.schedule|fix_asterisks|escapejs }}", "short": true }, {% endif %}