Add additional Telegram HTML tags

This commit is contained in:
JonnyWong16 2022-02-08 10:29:06 -08:00
commit 6d092b4984
No known key found for this signature in database
GPG key ID: B1F1F9807184697A
2 changed files with 13 additions and 7 deletions

View file

@ -1375,12 +1375,16 @@ def strip_tag(data, agent_id=None):
data = bleach.clean(data, tags=whitelist.keys(), attributes=whitelist, strip=True) data = bleach.clean(data, tags=whitelist.keys(), attributes=whitelist, strip=True)
elif agent_id == 13: elif agent_id == 13:
# Allow tags b, i, code, pre, a[href] for Telegram # Allow tags for Telegram
whitelist = {'b': [], # https://core.telegram.org/bots/api#html-style
'i': [], whitelist = {'b': [], 'strong': [],
'code': [], 'i': [], 'em': [],
'pre': [], 'u': [], 'ins': [],
'a': ['href']} 's': [], 'strike': [], 'del': [],
'span': ['class'], 'tg-spoiler': [],
'a': ['href'],
'code': ['class'],
'pre': []}
data = bleach.clean(data, tags=whitelist.keys(), attributes=whitelist, strip=True) data = bleach.clean(data, tags=whitelist.keys(), attributes=whitelist, strip=True)
elif agent_id in (10, 14, 20, 25): elif agent_id in (10, 14, 20, 25):

View file

@ -3963,7 +3963,9 @@ class TELEGRAM(Notifier):
{'label': 'Enable HTML Support', {'label': 'Enable HTML Support',
'value': self.config['html_support'], 'value': self.config['html_support'],
'name': 'telegram_html_support', 'name': 'telegram_html_support',
'description': 'Style your messages using these HTML tags: b, i, a[href], code, pre.', 'description': 'Enable to style your messages using these HTML tags:<br>'
'b, strong, i, em, u, ins, s, strike, del, span[class], '
'tg-spoiler, a[href], code[class], pre',
'input_type': 'checkbox' 'input_type': 'checkbox'
}, },
{'label': 'Disable Web Page Previews', {'label': 'Disable Web Page Previews',