From 619bdba5b29a319de92ae4e087393310c46b2462 Mon Sep 17 00:00:00 2001 From: Aevann Date: Sun, 7 May 2023 22:44:34 +0300 Subject: [PATCH] fix this https://rdrama.net/post/168774/marseynull-jershs-manifesto-just-dropped-marseyveryworriedtrans/4111081#context --- files/classes/comment.py | 3 +-- files/helpers/regex.py | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/files/classes/comment.py b/files/classes/comment.py index 818786ba6..bc4d21d84 100644 --- a/files/classes/comment.py +++ b/files/classes/comment.py @@ -23,8 +23,7 @@ def normalize_urls_runtime(body, v): if v.reddit != 'old.reddit.com': body = reddit_to_vreddit_regex.sub(rf'\1https://{v.reddit}/\2/', body) if v.nitter: - body = body.replace('https://twitter.com/', 'https://nitter.lacontrevoie.fr/') - body = body.replace('https://nitter.lacontrevoie.fr/i/', 'https://twitter.com/i/') + body = twitter_to_nitter_regex.sub(r'\1https://nitter.lacontrevoie.fr/', body) if v.imginn: body = body.replace('https://instagram.com/p/', 'https://imginn.com/p/') return body diff --git a/files/helpers/regex.py b/files/helpers/regex.py index 95c3bdbb5..0e74500b0 100644 --- a/files/helpers/regex.py +++ b/files/helpers/regex.py @@ -101,6 +101,7 @@ greentext_regex = re.compile("(\n|^)>([^ >][^\n]*)", flags=re.A) ascii_only_regex = re.compile("[ -~]+", flags=re.A) reddit_to_vreddit_regex = re.compile('(^|>|")https:\/\/old.reddit.com\/(r|u)\/', flags=re.A) +twitter_to_nitter_regex = re.compile('(^|>|")https:\/\/twitter.com\/(?!i\/)', flags=re.A) reddit_domain_regex = re.compile("(^|\s|\()https?:\/\/(reddit\.com|(?:(?:[A-z]{2})(?:-[A-z]{2})" "?|beta|i|m|pay|ssl|www|new|alpha)\.reddit\.com|libredd\.it|teddit\.net)\/(r|u)\/", flags=re.A) color_regex = re.compile("[a-f0-9]{6}", flags=re.A)