From 7d8476a11d1b3b08e1104a9446e8e30a271b6c4d Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Sat, 6 Nov 2021 20:06:04 +0200 Subject: [PATCH] fdfd --- files/helpers/sanitize.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/files/helpers/sanitize.py b/files/helpers/sanitize.py index c672d7f38..8828ae202 100644 --- a/files/helpers/sanitize.py +++ b/files/helpers/sanitize.py @@ -117,7 +117,7 @@ def sanitize(sanitized, noimages=False): if tag.get("src") and "pp20" not in tag.get("class", ""): - tag["rel"] = "nofollow noopener noreferrer" + if site not in tag["src"] and not tag["src"].startswith('/'): tag["rel"] = "nofollow noopener noreferrer" tag["class"] = "in-comment-image" tag["loading"] = "lazy" tag["data-src"] = tag["src"] @@ -125,7 +125,7 @@ def sanitize(sanitized, noimages=False): link = soup.new_tag("a") link["href"] = tag["data-src"] - link["rel"] = "nofollow noopener noreferrer" + if site not in tag["href"] and not tag["href"].startswith('/'): link["rel"] = "nofollow noopener noreferrer" link["target"] = "_blank" link["onclick"] = f"expandDesktopImage('{tag['data-src']}');" link["data-bs-toggle"] = "modal" @@ -225,8 +225,8 @@ def sanitize(sanitized, noimages=False): sanitized = sanitized.replace(rd, "https://old.reddit.com/") sanitized = sanitized.replace("old.reddit.com/gallery", "new.reddit.com/gallery") - sanitized = re.sub(' (https:\/\/[^ <>]*)', r' \1', sanitized) - sanitized = re.sub('

(https:\/\/[^ <>]*)', r'

\1

', sanitized) + sanitized = re.sub(' (https:\/\/[^ <>]*)', r' \1', sanitized) + sanitized = re.sub('

(https:\/\/[^ <>]*)', r'

\1

', sanitized) return sanitized