From da19ef96d13782c2fce0188536a4b2556891cbfe Mon Sep 17 00:00:00 2001 From: Aevann Date: Wed, 15 Mar 2023 04:46:54 +0200 Subject: [PATCH] fix images again --- files/helpers/media.py | 2 +- files/helpers/regex.py | 2 +- files/helpers/sanitize.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/files/helpers/media.py b/files/helpers/media.py index 3b756c37d..5f1bab3a1 100644 --- a/files/helpers/media.py +++ b/files/helpers/media.py @@ -57,7 +57,7 @@ def process_files(files, v, body): name = f'/images/{time.time()}'.replace('.','') + '.webp' file.save(name) url = process_image(name, v) - body = body.replace(f'[{file.filename}]', f'{url} ', 1) + body = body.replace(f'[{file.filename}]', f'{url} ', 1) elif file.content_type.startswith('video/'): body = body.replace(f'[{file.filename}]', process_video(file, v), 1) elif file.content_type.startswith('audio/'): diff --git a/files/helpers/regex.py b/files/helpers/regex.py index 59d3011b5..c8412148b 100644 --- a/files/helpers/regex.py +++ b/files/helpers/regex.py @@ -82,7 +82,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}}(\.|\?format=)({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_no_gif = image_regex_extensions.replace('|gif', '') imgur_regex = re.compile(f'(https:\/\/i\.imgur\.com\/[a-z0-9]+)\.({image_regex_extensions_no_gif})', flags=re.I|re.A) diff --git a/files/helpers/sanitize.py b/files/helpers/sanitize.py index 312ceb824..a83004b41 100644 --- a/files/helpers/sanitize.py +++ b/files/helpers/sanitize.py @@ -344,7 +344,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)\7', 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)