Aevann 2023-01-22 11:04:09 +02:00
parent 4cc1635bac
commit e8323127f9
2 changed files with 2 additions and 2 deletions

View File

@ -79,7 +79,7 @@ audio_regex_extensions = '|'.join(AUDIO_FORMATS)
audio_sub_regex = re.compile(f'(<p>[^<]*)(https:\/\/([a-z0-9-]+\.)*({hosts})\/[\w:~,()\-.#&\/=?@%;+]*?\.({audio_regex_extensions}))', flags=re.A) audio_sub_regex = re.compile(f'(<p>[^<]*)(https:\/\/([a-z0-9-]+\.)*({hosts})\/[\w:~,()\-.#&\/=?@%;+]*?\.({audio_regex_extensions}))', flags=re.A)
image_regex_extensions = '|'.join(IMAGE_FORMATS) 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', '') 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) imgur_regex = re.compile(f'(https:\/\/i\.imgur\.com\/[a-z0-9]+)\.({image_regex_extensions})', flags=re.I|re.A)

View File

@ -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 = linefeeds_regex.sub(r'\1\n\n\2', sanitized)
sanitized = greentext_regex.sub(r'\1<g>\>\2</g>', sanitized) sanitized = greentext_regex.sub(r'\1<g>\>\2</g>', 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 = image_check_regex.sub(r'\1', sanitized)
sanitized = link_fix_regex.sub(r'\1https://\2', sanitized) sanitized = link_fix_regex.sub(r'\1https://\2', sanitized)