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','')