fix multipinging (hopefully this doesnt break other shit)

remotes/1693045480750635534/spooky-22
Aevann1 2022-08-17 21:41:09 +02:00
parent 0cae055403
commit 0715ab3e64
2 changed files with 4 additions and 9 deletions

View File

@ -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)

View File

@ -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)}<a href="/id/{u.id}"><img loading="lazy" src="/pp/{u.id}">@{u.username}</a>''', 1)
sanitized = sanitized.replace(i.group(0), f'''<a href="/id/{u.id}"><img loading="lazy" src="/pp/{u.id}">@{u.username}</a>{i.group(4)}''')
soup = BeautifulSoup(sanitized, 'lxml')