vvvvvvvvvvvvvvv

This commit is contained in:
Aevann1 2022-01-27 19:04:02 +02:00
parent 46f29624cb
commit 09fe6f5a07
8 changed files with 30 additions and 30 deletions

View file

@ -105,14 +105,14 @@ def sanitize(sanitized, noimages=False, alert=False, comment=False, edit=False):
sanitized = sanitized.replace("\ufeff", "").replace("𒐪","").replace("<script","").replace('','')
if alert:
for i in re.finditer("<p>@((\w|-){1,25})", sanitized):
for i in re.finditer("<p>@((\w|-){1,25})", sanitized, flags=re.A):
u = get_user(i.group(1), graceful=True)
if u:
sanitized = sanitized.replace(i.group(0), f'''<p><a href="/id/{u.id}"><img alt="@{u.username}'s profile picture" loading="lazy" src="/uid/{u.id}/pic" class="pp20">@{u.username}</a>''', 1)
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)
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, flags=re.A)
for i in re.finditer('(^|\s|\n|<p>)@((\w|-){1,25})', sanitized):
for i in re.finditer('(^|\s|\n|<p>)@((\w|-){1,25})', sanitized, flags=re.A):
u = get_user(i.group(2), graceful=True)
if u and (not g.v.any_block_exists(u) or g.v.admin_level > 1):
@ -168,7 +168,7 @@ def sanitize(sanitized, noimages=False, alert=False, comment=False, edit=False):
tag["target"] = "_blank"
tag["rel"] = "nofollow noopener noreferrer"
if re.match("https?://\S+", str(tag.string)):
if re.match("https?://\S+", str(tag.string), flags=re.A):
try: tag.string = tag["href"]
except: tag.string = ""
@ -179,7 +179,7 @@ def sanitize(sanitized, noimages=False, alert=False, comment=False, edit=False):
if comment: marseys_used = set()
emojis = list(re.finditer("[^a]>\s*(:[!#]{0,2}\w+:\s*)+<\/", sanitized))
emojis = list(re.finditer("[^a]>\s*(:[!#]{0,2}\w+:\s*)+<\/", sanitized, flags=re.A))
if len(emojis) > 20: edit = True
for i in emojis:
old = i.group(0)