diff --git a/files/helpers/sanitize.py b/files/helpers/sanitize.py index db4daa9a81..33b78acd8d 100644 --- a/files/helpers/sanitize.py +++ b/files/helpers/sanitize.py @@ -161,6 +161,7 @@ def sanitize(sanitized, noimages=False): tag["style"] = "max-height: 100px; max-width: 100%;" tag["class"] = "in-comment-image rounded-sm my-2" tag["loading"] = "lazy" + tag["data-src"] = tag["src"] link = soup.new_tag("a") link["href"] = tag["src"] @@ -171,6 +172,8 @@ def sanitize(sanitized, noimages=False): link["data-bs-toggle"] = "modal" link["data-bs-target"] = "#expandImageModal" + tag["src"] = "" + tag.wrap(link) #disguised link preventer @@ -220,10 +223,10 @@ def sanitize(sanitized, noimages=False): if emoji.startswith("!"): emoji = emoji[1:] if path.isfile(f'./files/assets/images/emojis/{emoji}.webp'): - new = re.sub(f'\w*(?', new) + new = re.sub(f'\w*(?', new) elif path.isfile(f'./files/assets/images/emojis/{emoji}.webp'): - new = re.sub(f'\w*(?', new) + new = re.sub(f'\w*(?', new) if emoji in session["favorite_emojis"]: session["favorite_emojis"][emoji] += 1 else: session["favorite_emojis"][emoji] = 1 @@ -236,10 +239,10 @@ def sanitize(sanitized, noimages=False): if emoji.startswith("!"): emoji = emoji[1:] if path.isfile(f'./files/assets/images/emojis/{emoji}.webp'): - sanitized = re.sub(f'\w*(?', sanitized) + sanitized = re.sub(f'\w*(?', sanitized) elif path.isfile(f'./files/assets/images/emojis/{emoji}.webp'): - sanitized = re.sub(f'\w*(?', sanitized) + sanitized = re.sub(f'\w*(?', sanitized) if emoji in session["favorite_emojis"]: session["favorite_emojis"][emoji] += 1 else: session["favorite_emojis"][emoji] = 1 @@ -251,22 +254,22 @@ def sanitize(sanitized, noimages=False): for i in re.finditer('" target="_blank">(https://youtube.com/watch\?v\=.*?)', sanitized): url = i.group(1) replacing = f'{url}' - htmlsource = f'
' + htmlsource = f'' sanitized = sanitized.replace(replacing, htmlsource.replace("watch?v=", "embed/")) for i in re.finditer('{url}' - htmlsource = f'' + htmlsource = f'' sanitized = sanitized.replace(replacing, htmlsource) for i in re.finditer('(https:.*?\.mp4)
', sanitized): - sanitized = sanitized.replace(i.group(0), f'') + sanitized = sanitized.replace(i.group(0), f'
') for i in re.finditer('{url}' - htmlsource = f'' + htmlsource = f'' sanitized = sanitized.replace(replacing, htmlsource) for rd in ["https://reddit.com/", "https://new.reddit.com/", "https://www.reddit.com/", "https://redd.it/"]: