diff --git a/files/helpers/sanitize.py b/files/helpers/sanitize.py index e5425bf23..6ed408625 100644 --- a/files/helpers/sanitize.py +++ b/files/helpers/sanitize.py @@ -109,18 +109,18 @@ def sanitize(sanitized, noimages=False, alert=False, comment=False): for i in re.finditer("
@((\w|-){1,25})", sanitized): u = get_user(i.group(1), graceful=True) if u: - sanitized = sanitized.replace(i.group(0), f'''
@{u.username}''') + sanitized = sanitized.replace(i.group(0), f'''
@{u.username}''', 1) else: sanitized = re.sub('(^|\s|\n|
)\/?((r|u)\/\w{3,25})', r'\1\2', sanitized) - for i in re.finditer('(^|\s|\n|
)@((\w|-){1,25})($|\s|\n|
| )', sanitized): + for i in re.finditer('(^|\s|\n|)@((\w|-){1,25})', sanitized): u = get_user(i.group(2), graceful=True) if u and (not g.v.any_block_exists(u) or g.v.admin_level > 1): if noimages: - sanitized = sanitized.replace(i.group(0), f'{i.group(1)}@{u.username}{i.group(4)}') + sanitized = sanitized.replace(i.group(0), f'{i.group(1)}@{u.username}', 1) else: - sanitized = sanitized.replace(i.group(0), f'''{i.group(1)}@{u.username}{i.group(4)}''') + sanitized = sanitized.replace(i.group(0), f'''{i.group(1)}@{u.username}''', 1) for i in re.finditer('https://i\.imgur\.com/(([^_]*?)\.(jpg|png|jpeg))', sanitized):