diff --git a/files/classes/comment.py b/files/classes/comment.py index 6d6cd7861..6b5583d6d 100644 --- a/files/classes/comment.py +++ b/files/classes/comment.py @@ -69,7 +69,7 @@ def normalize_urls_runtime(body, v): body = twitter_to_nitter_regex.sub(r'\1https://nitter.net/', body) if v and v.imgsed: - body = body.replace('https://instagram.com/', 'https://imgsed.com/') + body = instagram_to_imgsed_regex.sub(r'\1https://imgsed.com/', body) if not v or v.controversial: captured = [] diff --git a/files/helpers/regex.py b/files/helpers/regex.py index a8bbc3eaa..4047b6b6a 100644 --- a/files/helpers/regex.py +++ b/files/helpers/regex.py @@ -128,6 +128,8 @@ allowed_domain_regex = re.compile("[a-z0-9\-.]+", flags=re.I|re.A) twitter_to_nitter_regex = re.compile('(^|>|")https:\/\/twitter.com\/(?!i\/)', flags=re.A) +instagram_to_imgsed_regex = re.compile('(^|>|")https:\/\/instagram.com\/(?!reel\/)', flags=re.A) + color_regex = re.compile("[a-f0-9]{6}", flags=re.A) # lazy match on the .*?, only match if there is trailing stuff