From 77c1f9638353dc63064f236e96c620635a527875 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Sat, 2 Jul 2022 02:54:59 +0200 Subject: [PATCH] remove empty anchor tags --- files/helpers/sanitize.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/files/helpers/sanitize.py b/files/helpers/sanitize.py index cb13aec69..b51c02403 100644 --- a/files/helpers/sanitize.py +++ b/files/helpers/sanitize.py @@ -221,6 +221,8 @@ def sanitize(sanitized, edit=False): a.append(tag) for tag in soup.find_all("a"): + if not tag.contents or not str(tag.contents[0]).strip(): + tag.extract() if tag.get("href") and fishylinks_regex.fullmatch(str(tag.string)): tag.string = tag["href"]