From ed7baccb5c014725bcd1105a8d6a5e3e8d4b1e82 Mon Sep 17 00:00:00 2001 From: Aevann Date: Sun, 26 Mar 2023 14:28:32 +0200 Subject: [PATCH] minor fix --- files/helpers/sanitize.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/files/helpers/sanitize.py b/files/helpers/sanitize.py index e6928c9f4..9c5ae1947 100644 --- a/files/helpers/sanitize.py +++ b/files/helpers/sanitize.py @@ -651,12 +651,13 @@ def complies_with_chud(obj): return True #check for agendaposter_phrase in body_html - excluded_tags = {'del','sub','sup','marquee','spoiler','lite-youtube','video','audio'} - soup = BeautifulSoup(old_body_html, 'lxml') - tags = soup.html.body.find_all(lambda tag: tag.name not in excluded_tags and not tag.attrs, recursive=False) - for tag in tags: - for text in tag.find_all(text=True, recursive=False): - if obj.author.agendaposter_phrase in text.lower(): - return True + if old_body_html: + excluded_tags = {'del','sub','sup','marquee','spoiler','lite-youtube','video','audio'} + soup = BeautifulSoup(old_body_html, 'lxml') + tags = soup.html.body.find_all(lambda tag: tag.name not in excluded_tags and not tag.attrs, recursive=False) + for tag in tags: + for text in tag.find_all(text=True, recursive=False): + if obj.author.agendaposter_phrase in text.lower(): + return True return False