From c2185c4ce541b0a6e5752fb6da7e199cb972401b Mon Sep 17 00:00:00 2001 From: JonnyWong16 Date: Sat, 7 Sep 2019 16:37:38 -0700 Subject: [PATCH] Fix notificaiton parameter prefix and suffix not being substituted correctly --- plexpy/notification_handler.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/plexpy/notification_handler.py b/plexpy/notification_handler.py index d17f7739..036a416f 100644 --- a/plexpy/notification_handler.py +++ b/plexpy/notification_handler.py @@ -1101,6 +1101,8 @@ def build_notify_text(subject='', body='', notify_action=None, parameters=None, def strip_tag(data, agent_id=None): + # Substitute temporary tokens for < and > in parameter prefix and suffix + data = re.sub(r'{.+?}', lambda m: m.group().replace('<', '%temp_lt_token%').replace('>', '%temp_gt_token%'), data) if agent_id == 7: # Allow tags b, i, u, a[href], font[color] for Pushover @@ -1109,11 +1111,11 @@ def strip_tag(data, agent_id=None): 'u': [], 'a': ['href'], 'font': ['color']} - return 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): # Don't remove tags for Email, Slack, and Discord - return data + pass elif agent_id == 13: # Allow tags b, i, code, pre, a[href] for Telegram @@ -1122,11 +1124,14 @@ def strip_tag(data, agent_id=None): 'code': [], 'pre': [], 'a': ['href']} - return bleach.clean(data, tags=whitelist.keys(), attributes=whitelist, strip=True) + data = bleach.clean(data, tags=whitelist.keys(), attributes=whitelist, strip=True) else: whitelist = {} - return bleach.clean(data, tags=whitelist.keys(), attributes=whitelist, strip=True) + data = bleach.clean(data, tags=whitelist.keys(), attributes=whitelist, strip=True) + + # Resubstitute temporary tokens for < and > in parameter prefix and suffix + return data.replace('%temp_lt_token%', '<').replace('%temp_gt_token%', '>') def format_group_index(group_keys):