From dcc63c78344c55ed9822d17e4602154689973027 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Tue, 12 Jul 2022 22:30:00 +0200 Subject: [PATCH] add more image validation (to fix this https://chapotraphouse.club/post/18459/marseycapywalking-megathread-for-bugs-and-suggestions/2298173?context=8#context) --- files/helpers/sanitize.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/files/helpers/sanitize.py b/files/helpers/sanitize.py index b3b1519c6..7e5e24ed3 100644 --- a/files/helpers/sanitize.py +++ b/files/helpers/sanitize.py @@ -228,6 +228,12 @@ def sanitize(sanitized, edit=False): for tag in soup.find_all("img"): if tag.get("src") and not tag["src"].startswith('/pp/'): + if not is_safe_url(tag["src"]): + a = soup.new_tag("a", href=tag["src"], rel="nofollow noopener noreferrer", target="_blank") + a.string = tag["src"] + tag.replace_with(a) + continue + tag["loading"] = "lazy" tag["data-src"] = tag["src"] tag["src"] = "/i/l.webp"