From df803791ef771a915f162eb402cfb7c869b39a89 Mon Sep 17 00:00:00 2001 From: Aevann Date: Sat, 21 Jan 2023 06:18:02 +0200 Subject: [PATCH] exclude snappy from fishylinks_regex --- files/helpers/actions.py | 2 +- files/helpers/sanitize.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/files/helpers/actions.py b/files/helpers/actions.py index 67d6d246d..90ef9ac87 100644 --- a/files/helpers/actions.py +++ b/files/helpers/actions.py @@ -149,7 +149,7 @@ def execute_snappy(post:Submission, v:User): archive_url(href) body = body.strip()[:COMMENT_BODY_LENGTH_LIMIT] - body_html = sanitize(body) + body_html = sanitize(body, snappy=True) if len(body_html) == 0: return diff --git a/files/helpers/sanitize.py b/files/helpers/sanitize.py index 6099ceb39..9b99c17e5 100644 --- a/files/helpers/sanitize.py +++ b/files/helpers/sanitize.py @@ -238,7 +238,7 @@ chud_images = [f'![](/i/chud/{f})' for f in chud_images] chud_images.extend([':#trumpjaktalking:', ':#reposthorse:']) @with_sigalrm_timeout(10) -def sanitize(sanitized, golden=True, limit_pings=0, showmore=True, count_marseys=False, torture=False, sidebar=False): +def sanitize(sanitized, golden=True, limit_pings=0, showmore=True, count_marseys=False, torture=False, sidebar=False, snappy=False): sanitized = sanitized.strip() sanitized = utm_regex.sub('', sanitized) @@ -318,7 +318,7 @@ def sanitize(sanitized, golden=True, limit_pings=0, showmore=True, count_marseys 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)): + if not snappy and tag.get("href") and fishylinks_regex.fullmatch(str(tag.string)): tag.string = tag["href"]