forked from rDrama/rDrama
1
0
Fork 0

add target="_blank" to all external urls

master
Aevann1 2022-07-12 22:29:27 +02:00
parent a8a4e0e7f1
commit fb73fa0612
1 changed files with 2 additions and 1 deletions

View File

@ -209,7 +209,7 @@ def sanitize(sanitized, edit=False):
sanitized = sanitized.replace('','').replace('','').replace("\ufeff", "").replace("𒐪","")
sanitized = reddit_regex.sub(r'\1<a href="https://old.reddit.com/\2" rel="nofollow noopener noreferrer">/\2</a>', sanitized)
sanitized = reddit_regex.sub(r'\1<a href="https://old.reddit.com/\2" rel="nofollow noopener noreferrer" target="_blank">/\2</a>', sanitized)
sanitized = sub_regex.sub(r'\1<a href="/\2">/\2</a>', 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)