diff --git a/files/helpers/regex.py b/files/helpers/regex.py index 90849a231..41be59ccd 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 3d57e6c14..b653aa060 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')