From dc59bfc5a544cad6a53c7482d86b744ae9dfef50 Mon Sep 17 00:00:00 2001 From: Aevann Date: Sun, 6 Aug 2023 05:47:12 +0300 Subject: [PATCH] fix this https://rdrama.net/post/18459/marseycapywalking-megathread-for-bugs-and-suggestions/4738827#context --- files/helpers/regex.py | 2 +- files/helpers/sanitize.py | 19 +++++++++---------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/files/helpers/regex.py b/files/helpers/regex.py index b8e9829b5..184049d23 100644 --- a/files/helpers/regex.py +++ b/files/helpers/regex.py @@ -119,7 +119,7 @@ imgur_regex = re.compile(f'(https:\/\/i\.imgur\.com\/[a-z0-9]+)\.({image_regex_e giphy_regex = re.compile('(https:\/\/media\.giphy\.com\/media\/[a-z0-9]+\/giphy)\.gif', flags=re.I|re.A) -youtube_regex = re.compile('((

|

', sanitized) sanitized = audio_sub_regex.sub(r'', sanitized) @@ -601,9 +592,17 @@ def sanitize(sanitized, golden=True, limit_pings=0, showmore=False, count_emojis link["target"] = "_blank" link["rel"] = "nofollow noopener" - sanitized = str(soup).replace('','').replace('','').replace('/>','>') + captured = [] + for i in youtube_regex.finditer(sanitized): + if i.group(0) in captured: continue + captured.append(i.group(0)) + + html = handle_youtube_links(i.group(1)) + if html: + sanitized = sanitized.replace(i.group(0), html) + if '
' not in sanitized and blackjack != "rules":
 		sanitized = sanitized.replace('\n','')