diff --git a/files/helpers/sanitize.py b/files/helpers/sanitize.py index 04c5cbeb3..3bd64472d 100644 --- a/files/helpers/sanitize.py +++ b/files/helpers/sanitize.py @@ -697,7 +697,7 @@ def allowed_attributes_emojis(tag, name, value): @with_sigalrm_timeout(2) -def filter_emojis_only(title, golden=True, count_emojis=False, graceful=False): +def filter_emojis_only(title, golden=True, count_emojis=False, graceful=False, is_post_title=False): title = title.replace("\n", "").replace("\r", "").replace("\t", "").replace('<','<').replace('>','>') @@ -720,9 +720,11 @@ def filter_emojis_only(title, golden=True, count_emojis=False, graceful=False): abort(400) title = title.strip() - soup = BeautifulSoup(title, 'lxml') - text = soup.html.body.text.strip() - if not text: title = f'--- {title} ---' + + if is_post_title: + soup = BeautifulSoup(title, 'lxml') + text = soup.html.body.text.strip() + if not text: title = f'--- {title} ---' return title diff --git a/files/routes/posts.py b/files/routes/posts.py index 4d3335b5d..d7e4eb2e1 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -436,7 +436,7 @@ def submit_post(v, sub=None): if SITE == 'rdrama.net' and v.id == 10947: sub = 'mnn' - title_html = filter_emojis_only(title, graceful=True, count_emojis=True) + title_html = filter_emojis_only(title, graceful=True, count_emojis=True, is_post_title=True) if v.marseyawarded and not marseyaward_title_regex.fullmatch(title_html): abort(400, "You can only type marseys!") @@ -992,7 +992,7 @@ def edit_post(pid, v): if title != p.title: - title_html = filter_emojis_only(title, golden=False) + title_html = filter_emojis_only(title, golden=False, is_post_title=True) if v.id == p.author_id and v.marseyawarded and not marseyaward_title_regex.fullmatch(title_html): abort(403, "You can only type marseys!")