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"]