From 90e90871188bfcbfe8e0ed837f390b4420aa6312 Mon Sep 17 00:00:00 2001 From: Aevann Date: Sat, 20 Apr 2024 18:26:20 +0200 Subject: [PATCH] limit to scale to 99 to fix this https://watchpeopledie.tv/notification/3148751#context --- files/helpers/bleach_body.py | 4 ++-- files/helpers/regex.py | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/files/helpers/bleach_body.py b/files/helpers/bleach_body.py index e461a139f..76c115038 100644 --- a/files/helpers/bleach_body.py +++ b/files/helpers/bleach_body.py @@ -3,7 +3,7 @@ from bleach.css_sanitizer import CSSSanitizer from bleach.linkifier import LinkifyFilter import functools -from files.helpers.regex import sanitize_url_regex +from files.helpers.regex import sanitize_url_regex, excessive_css_scale_regex from files.helpers.config.const import * allowed_tags = ('a','alpha','audio','b','big','blink','blockquote','br','center','code','del','details','em','g','gl','h1','h2','h3','h4','h5','h6','hr','i','img','li','lite-youtube','marquee','ol','p','pre','rp','rt','ruby','small','span','spoiler','strike','strong','sub','summary','sup','table','tbody','td','th','thead','tr','u','ul','video') @@ -13,7 +13,7 @@ allowed_css_properties = ('background-color', 'color', 'filter', 'font-weight', def allowed_attributes(tag, name, value): if name == 'style': value = value.lower() - if 'transform' in value and 'scale' in value and ('rotate' in value or 'skew' in value): + if 'transform' in value and 'scale' in value and excessive_css_scale_regex.search(value): return False return True diff --git a/files/helpers/regex.py b/files/helpers/regex.py index 76da938c8..d545c973e 100644 --- a/files/helpers/regex.py +++ b/files/helpers/regex.py @@ -159,6 +159,8 @@ pronouns_regex = re.compile("(\w{1,7})\/\w{1,7}(\/\w{1,7})?", flags=re.A) html_title_regex = re.compile("(.{1,200})", flags=re.I) +excessive_css_scale_regex = re.compile("scale\(.*?(\d{3})", flags=re.A) + commands = { "fortune": FORTUNE_REPLIES, "factcheck": FACTCHECK_REPLIES,