From 0715ab3e64616247c596828520af9a3e0919afe7 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Wed, 17 Aug 2022 21:41:09 +0200 Subject: [PATCH] fix multipinging (hopefully this doesnt break other shit) --- files/helpers/regex.py | 11 +++-------- files/helpers/sanitize.py | 2 +- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/files/helpers/regex.py b/files/helpers/regex.py index 90849a2318..41be59ccd1 100644 --- a/files/helpers/regex.py +++ b/files/helpers/regex.py @@ -2,14 +2,9 @@ import re from .const import * from random import choice, choices -if SITE_NAME == 'PCM': - valid_username_chars = 'a-zA-Z0-9_\-А-я' - valid_username_regex = re.compile("^[a-zA-Z0-9_\-А-я]{3,25}$", flags=re.A) - mention_regex = re.compile('(^|\s|>)@(([a-zA-Z0-9_\-А-я]){3,25})(?![^<]*<\/(code|pre|a)>)', flags=re.A) -else: - valid_username_chars = 'a-zA-Z0-9_\-' - valid_username_regex = re.compile("^[a-zA-Z0-9_\-]{3,25}$", flags=re.A) - mention_regex = re.compile('(^|\s|>)@(([a-zA-Z0-9_\-]){1,25})(?![^<]*<\/(code|pre|a)>)', flags=re.A) +valid_username_chars = 'a-zA-Z0-9_\-' +valid_username_regex = re.compile("^[a-zA-Z0-9_\-]{3,25}$", flags=re.A) +mention_regex = re.compile('(?<=(\s|>))@(([a-zA-Z0-9_\-]){1,25})($|\s|<\/p>)', flags=re.A) valid_password_regex = re.compile("^.{8,100}$", flags=re.A) diff --git a/files/helpers/sanitize.py b/files/helpers/sanitize.py index 3d57e6c144..b653aa0601 100644 --- a/files/helpers/sanitize.py +++ b/files/helpers/sanitize.py @@ -254,7 +254,7 @@ def sanitize(sanitized, edit=False, limit_pings=False, showmore=True): m = [m for m in matches if u.username.lower() == m.group(2).lower() or u.original_username.lower() == m.group(2).lower()] for i in m: if not (v and v.any_block_exists(u)) or (v and v.admin_level >= 2): - sanitized = sanitized.replace(i.group(0), f'''{i.group(1)}@{u.username}''', 1) + sanitized = sanitized.replace(i.group(0), f'''@{u.username}{i.group(4)}''') soup = BeautifulSoup(sanitized, 'lxml')