master
Aevann1 2022-01-12 05:28:49 +02:00
parent 4a4efee50d
commit e0d9ef6094
1 changed files with 3 additions and 3 deletions

View File

@ -109,7 +109,7 @@ def sanitize(sanitized, noimages=False, alert=False):
for i in re.finditer("<p>@((\w|-){1,25})", sanitized):
u = get_user(i.group(1), graceful=True)
if u:
sanitized = re.sub("<p>@((\w|-){1,25})", f'<p><a href="/id/{u.id}"><img loading="lazy" src="/uid/{u.id}/pic" class="pp20">@{u.username}</a>', sanitized)
sanitized = sanitized.replace(i.group(0), f'<p><a href="/id/{u.id}"><img loading="lazy" src="/uid/{u.id}/pic" class="pp20">@{u.username}</a>')
else:
sanitized = re.sub('(^|\s|\n|<p>)\/?((r|u)\/\w{3,25})', r'\1<a href="https://old.reddit.com/\2" rel="nofollow noopener noreferrer">\2</a>', sanitized)
@ -118,9 +118,9 @@ def sanitize(sanitized, noimages=False, alert=False):
if u and (not g.v.any_block_exists(u) or g.v.admin_level > 1):
if noimages:
sanitized = re.sub("(^|\s|\n|<p>)@((\w|-){1,25})", rf'\1<a href="/id/{u.id}">@{u.username}</a>', sanitized)
sanitized = sanitized.replace(i.group(0), f'{i.group(1)}<a href="/id/{u.id}">@{u.username}</a>')
else:
sanitized = re.sub("(^|\s|\n|<p>)@((\w|-){1,25})", rf'\1<a href="/id/{u.id}"><img loading="lazy" src="/uid/{u.id}/pic" class="pp20">@{u.username}</a>', sanitized)
sanitized = sanitized.replace(i.group(0), f'{i.group(1)}<a href="/id/{u.id}"><img loading="lazy" src="/uid/{u.id}/pic" class="pp20">@{u.username}</a>')
for i in re.finditer('https://i\.imgur\.com/(([^_]*?)\.(jpg|png|jpeg))', sanitized):