-
Problem report
-
Resolution: Fixed
-
Trivial
-
5.0.17, 5.4.7, 6.0.0alpha6, 6.0 (plan)
-
None
-
Sprint 82 (Nov 2021)
-
1
Telegram using MarkdownV2 syntax, but we don't nave a tool to escape special characters in user-defined and event macros. Some of this characters often used in names of host and etc.
Following the Telegram documentation special characters should be escaped via backslash. Users now have only 3 ways:
1. not use md characters in zabbix
2. escape all conent of {ALERT.SUBJECT} and {ALERT.MESSAGE} in JS (double ascape used cause we use JSON) like here:
escapeMarkup: function (str) { var length = str.length, result = '', markup = ['_', '*', '[', ']', '(', ')', '~', '`', '>', '#', '+', '-', '=', '|', '{', '}', '.', '!']; for (var i = 0; i < length; i++) { var char = str[i]; result += (markup.indexOf(char) !== -1) ? ('\\' + char) : char; } return result;
3. not use message templates, hardcode this in JS and use the same function for escaping only macro content
As my opinion would be great to add a escape function for non-word characters with escape-character as parameter to all macros like {HOST.HOST}.escape('\')