From 5c32c8215e5963a5761e5aef616b25cd0abfd6e6 Mon Sep 17 00:00:00 2001 From: Aevann Date: Sun, 26 Mar 2023 14:27:40 +0200 Subject: [PATCH] minor fix --- files/helpers/sanitize.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/files/helpers/sanitize.py b/files/helpers/sanitize.py index b80bd9608..e6928c9f4 100644 --- a/files/helpers/sanitize.py +++ b/files/helpers/sanitize.py @@ -637,11 +637,12 @@ def complies_with_chud(obj): old_body_html = obj.body_html #torture body_html - soup = BeautifulSoup(obj.body_html, 'lxml') - tags = soup.html.body.find_all(lambda tag: tag.name not in {'blockquote','codeblock','pre'} and tag.string, recursive=False) - for tag in tags: - tag.string.replace_with(torture_ap(tag.string, obj.author.username)) - obj.body_html = str(soup).replace('','').replace('','') + if obj.body_html: + soup = BeautifulSoup(obj.body_html, 'lxml') + tags = soup.html.body.find_all(lambda tag: tag.name not in {'blockquote','codeblock','pre'} and tag.string, recursive=False) + for tag in tags: + tag.string.replace_with(torture_ap(tag.string, obj.author.username)) + obj.body_html = str(soup).replace('','').replace('','') #torture title_html and check for agendaposter_phrase in plain title and leave if it's there if isinstance(obj, Submission):