From fb73fa06129334fa812c9013c2c8c7ad2dbc6abb Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Tue, 12 Jul 2022 22:29:27 +0200 Subject: [PATCH] add target="_blank" to all external urls --- files/helpers/sanitize.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/files/helpers/sanitize.py b/files/helpers/sanitize.py index 64bad0f2a..b3b1519c6 100644 --- a/files/helpers/sanitize.py +++ b/files/helpers/sanitize.py @@ -209,7 +209,7 @@ def sanitize(sanitized, edit=False): sanitized = sanitized.replace('‎','').replace('​','').replace("\ufeff", "").replace("𒐪","") - sanitized = reddit_regex.sub(r'\1/\2', sanitized) + sanitized = reddit_regex.sub(r'\1/\2', sanitized) sanitized = sub_regex.sub(r'\1/\2', sanitized) matches = [ m for m in mention_regex.finditer(sanitized) if m ] @@ -240,6 +240,7 @@ def sanitize(sanitized, edit=False): a = soup.new_tag("a", href=tag["data-src"]) if not is_site_url(a["href"]): a["rel"] = "nofollow noopener noreferrer" + a["target"] = "_blank" tag = tag.replace_with(a) a.append(tag)