From 7915eb83900450a85f268cad09ee849458ccc757 Mon Sep 17 00:00:00 2001 From: TLSM Date: Sun, 12 Jun 2022 02:22:38 -0400 Subject: [PATCH] Fix giant patting hand UI bug. Despite being very fun, this fixes the recently discovered bug where placing '#' or '!' within the 'pat:' suffix of a patted emoji causes the enclosing to not be given the proper CSS `display` or `position`, leading to the hand being sized relative to the comment bounding box rather than the emoji box. This should be backward compatible. The only posts it wont fix are existing ones with the giant hands. Main example being: https://rdrama.net/h/slackernews/post/76302/ --- files/helpers/sanitize.py | 8 +++++--- files/templates/util/assetcache.html | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/files/helpers/sanitize.py b/files/helpers/sanitize.py index 1567468278..5dc55c5a8b 100644 --- a/files/helpers/sanitize.py +++ b/files/helpers/sanitize.py @@ -63,7 +63,7 @@ def allowed_attributes(tag, name, value): if name in ['src','data-src']: return is_safe_url(value) if name == 'loading' and value == 'lazy': return True if name == 'data-bs-toggle' and value == 'tooltip': return True - if name in ['g','b'] and not value: return True + if name in ['g','b','data-pat'] and not value: return True if name in ['alt','title']: return True if name == 'referrpolicy' and value == 'no-referrer': return True return False @@ -93,6 +93,7 @@ def allowed_attributes(tag, name, value): if tag == 'span': if name == 'data-bs-toggle' and value == 'tooltip': return True + if name == 'data-pat' and not value: return True if name == 'title': return True if name == 'alt': return True return False @@ -145,11 +146,12 @@ def render_emoji(html, regexp, edit, marseys_used=set(), b=False): emoji_html = None if emoji.endswith('pat'): + attrs += ' data-pat' if path.isfile(f"files/assets/images/emojis/{emoji.replace('pat','')}.webp"): - emoji_html = f'{emoji_partial_pat.format(old, f"/e/{emoji[:-3]}.webp", attrs)}' + emoji_html = f'{emoji_partial_pat.format(old, f"/e/{emoji[:-3]}.webp", attrs)}' elif emoji.startswith('@'): if u := get_user(emoji[1:-3], graceful=True): - emoji_html = f'{emoji_partial_pat.format(old, f"/pp/{u.id}", attrs)}' + emoji_html = f'{emoji_partial_pat.format(old, f"/pp/{u.id}", attrs)}' elif path.isfile(f'files/assets/images/emojis/{emoji}.webp'): emoji_html = emoji_partial.format(old, f'/e/{emoji}.webp', attrs) diff --git a/files/templates/util/assetcache.html b/files/templates/util/assetcache.html index b0863a6050..b35caf21da 100644 --- a/files/templates/util/assetcache.html +++ b/files/templates/util/assetcache.html @@ -1,6 +1,6 @@ {%- set CACHE_VER = { - 'css/main.css': 234, + 'css/main.css': 301, 'css/4chan.css': 60, 'css/classic.css': 59,