From 005fc10e853a70f3a628c083925c5f6ce075f0b7 Mon Sep 17 00:00:00 2001 From: Aevann Date: Fri, 19 Apr 2024 22:58:36 +0200 Subject: [PATCH] fix reddit mentions being ruined by owoify --- files/helpers/owoify.py | 1 + files/helpers/regex.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/files/helpers/owoify.py b/files/helpers/owoify.py index b1d75c911..bc75b3a28 100644 --- a/files/helpers/owoify.py +++ b/files/helpers/owoify.py @@ -17,6 +17,7 @@ OWO_EXCLUDE_PATTERNS = [ sanitize_url_regex, # bare links mention_regex, # mentions group_mention_regex, #ping group mentions + reddit_mention_regex, #/u/ and /r/ command_regex, # markup commands ] diff --git a/files/helpers/regex.py b/files/helpers/regex.py index 06bafe4ff..76da938c8 100644 --- a/files/helpers/regex.py +++ b/files/helpers/regex.py @@ -253,7 +253,7 @@ sanitize_url_regex = re.compile( ###REDDIT #sanitizing -reddit_mention_regex = re.compile('([>\s])\/?(r|u)(\/[\w-]{2,25})' + NOT_IN_CODE_OR_LINKS, flags=re.I|re.A) +reddit_mention_regex = re.compile('(^|[>\s])\/?(r|u)(\/[\w-]{2,25})' + NOT_IN_CODE_OR_LINKS, flags=re.I|re.A) reddit_domain_regex = re.compile("(^|\s|\()https?:\/\/(redd.it\/|((www\.|new\.)?reddit\.com|redd\.it)\/(u\/(?![\w-]{2,25}\/s\/)|user\/|(r\/\w{2,25}\/)?comments\/|r\/\w{2,25}\/?$))", flags=re.A) reddit_comment_link_regex = re.compile("https:\/\/old.reddit.com\/r\/\w{2,25}\/comments(\/\w+){3}\/?.*", flags=re.A)