From e8323127f9a992db0d65b9d74ef3ca3989f7c3f6 Mon Sep 17 00:00:00 2001 From: Aevann Date: Sun, 22 Jan 2023 11:04:09 +0200 Subject: [PATCH] fix this https://stupidpol.site/post/141309/marseyxdmarseywall-twitter-influencer-seethemaxxing-after-being/3453484#context --- files/helpers/regex.py | 2 +- files/helpers/sanitize.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/files/helpers/regex.py b/files/helpers/regex.py index 2acca2020..aaec0161c 100644 --- a/files/helpers/regex.py +++ b/files/helpers/regex.py @@ -79,7 +79,7 @@ audio_regex_extensions = '|'.join(AUDIO_FORMATS) audio_sub_regex = re.compile(f'(

[^<]*)(https:\/\/([a-z0-9-]+\.)*({hosts})\/[\w:~,()\-.#&\/=?@%;+]*?\.({audio_regex_extensions}))', flags=re.A) image_regex_extensions = '|'.join(IMAGE_FORMATS) -image_regex = re.compile(f"(^|\s)(https:\/\/[\w\-.#&/=\?@%;+,:]{{5,250}}\.({image_regex_extensions})(\?[\w\-.#&/=\?@%;+,:]*)?)($|\s)", flags=re.I|re.A) +image_regex = re.compile(f"(^|\s)(https:\/\/[\w\-.#&/=\?@%;+,:]{{5,250}}(\.|\?format=)({image_regex_extensions})((\?|&)[\w\-.#&/=\?@%;+,:]*)?)($|\s)", flags=re.I|re.A) image_regex_extensions = image_regex_extensions.replace('|gif', '') imgur_regex = re.compile(f'(https:\/\/i\.imgur\.com\/[a-z0-9]+)\.({image_regex_extensions})', flags=re.I|re.A) diff --git a/files/helpers/sanitize.py b/files/helpers/sanitize.py index 9b99c17e5..c026c4430 100644 --- a/files/helpers/sanitize.py +++ b/files/helpers/sanitize.py @@ -255,7 +255,7 @@ def sanitize(sanitized, golden=True, limit_pings=0, showmore=True, count_marseys sanitized = linefeeds_regex.sub(r'\1\n\n\2', sanitized) sanitized = greentext_regex.sub(r'\1\>\2', sanitized) - sanitized = image_regex.sub(r'\1![](\2)\5', sanitized) + sanitized = image_regex.sub(r'\1![](\2)', sanitized) sanitized = image_check_regex.sub(r'\1', sanitized) sanitized = link_fix_regex.sub(r'\1https://\2', sanitized)