From 5f78b4e36581acb890c382b783d90e58a940c47c Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Wed, 22 Jun 2022 23:12:02 +0200 Subject: [PATCH] delete empty tags to prevent exploits --- files/helpers/sanitize.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/files/helpers/sanitize.py b/files/helpers/sanitize.py index 8649e990bd..5b3a109782 100644 --- a/files/helpers/sanitize.py +++ b/files/helpers/sanitize.py @@ -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"]