From 2dcd1288d71120bdeae61ef986aaa05325a7af08 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Fri, 26 Aug 2022 20:15:26 +0200 Subject: [PATCH] Revert "adjust audio and video embedding" This reverts commit e9d98e158cec0c6be548e9493e090939070e341b. --- files/helpers/regex.py | 4 ++-- files/helpers/sanitize.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/files/helpers/regex.py b/files/helpers/regex.py index e08c6ded8..1d85db1b8 100644 --- a/files/helpers/regex.py +++ b/files/helpers/regex.py @@ -61,8 +61,8 @@ torture_regex_exclude = re.compile('^\s*>', flags=re.A) image_check_regex = re.compile(f'!\[\]\(((?!(https:\/\/([a-z0-9-]+\.)*({hosts})\/|\/)).*?)\)', flags=re.A) -video_sub_regex = re.compile(f'(https:\/\/([a-z0-9-]+\.)*({hosts})\/[\w:~,()\-.#&\/=?@%;+]*?\.(mp4|webm|mov))', flags=re.A) -audio_sub_regex = re.compile(f'(https:\/\/([a-z0-9-]+\.)*({hosts})\/[\w:~,()\-.#&\/=?@%;+]*?\.(mp3|wav|ogg|aac|m4a|flac))', flags=re.A) +video_sub_regex = re.compile(f'(

[^<]*)(https:\/\/([a-z0-9-]+\.)*({hosts})\/[\w:~,()\-.#&\/=?@%;+]*?\.(mp4|webm|mov))', flags=re.A) +audio_sub_regex = re.compile(f'(

[^<]*)(https:\/\/([a-z0-9-]+\.)*({hosts})\/[\w:~,()\-.#&\/=?@%;+]*?\.(mp3|wav|ogg|aac|m4a|flac))', flags=re.A) imgur_regex = re.compile('(https:\/\/i\.imgur\.com\/[a-z0-9]+)\.(jpg|png|jpeg|webp)', flags=re.I|re.A) giphy_regex = re.compile('(https:\/\/media\.giphy\.com\/media\/[a-z0-9]+\/giphy)\.gif', flags=re.I|re.A) diff --git a/files/helpers/sanitize.py b/files/helpers/sanitize.py index 47a1031c2..d00e84749 100644 --- a/files/helpers/sanitize.py +++ b/files/helpers/sanitize.py @@ -319,8 +319,8 @@ def sanitize(sanitized, edit=False, limit_pings=0, showmore=True): sanitized = sanitized.replace(i.group(0), htmlsource) - sanitized = video_sub_regex.sub(r'', sanitized) - sanitized = audio_sub_regex.sub(r'', sanitized) + sanitized = video_sub_regex.sub(r'\1', sanitized) + sanitized = audio_sub_regex.sub(r'\1', sanitized) if not edit: for marsey in g.db.query(Marsey).filter(Marsey.name.in_(marseys_used)).all():