delete empty <a> tags to prevent exploits

remotes/1693045480750635534/spooky-22
Aevann1 2022-06-22 23:12:02 +02:00
parent b8321fd18d
commit 5f78b4e365
1 changed files with 3 additions and 1 deletions

View File

@ -227,7 +227,9 @@ def sanitize(sanitized, alert=False, edit=False):
tag['referrerpolicy'] = "no-referrer"
for tag in soup.find_all("a"):
if tag.get("href") and fishylinks_regex.fullmatch(str(tag.string)):
if not tag.string or not tag.get("href"):
tag.decompose()
elif fishylinks_regex.fullmatch(str(tag.string)):
tag.string = tag["href"]