forked from rDrama/rDrama
1
0
Fork 0
master
Aevann1 2022-07-02 02:00:02 +00:00
commit 08559186cb
4 changed files with 13 additions and 9 deletions

View File

@ -45,8 +45,8 @@ strikethrough_regex = re.compile('(^|\s|>)~{1,2}([^~]+)~{1,2}', flags=re.A)
mute_regex = re.compile("/mute @([a-z0-9_\-]{3,25}) ([0-9])+", flags=re.A)
emoji_regex = re.compile(f"<p>\s*(:[!#@]{{0,3}}[{valid_username_chars}]+:\s*)+<\/p>", flags=re.A)
emoji_regex2 = re.compile(f'(?<!"):([!#@{valid_username_chars}]{{1,31}}?):', flags=re.A)
emoji_regex3 = re.compile(f'(?<!"):([!@{valid_username_chars}]{{1,31}}?):', flags=re.A)
emoji_regex2 = re.compile(f'(?<!"):([!#@{valid_username_chars}]{{1,34}}?):', flags=re.A)
emoji_regex3 = re.compile(f'(?<!"):([!@{valid_username_chars}]{{1,34}}?):', flags=re.A)
snappy_url_regex = re.compile('<a href="(https?:\/\/.+?)".*?>(.+?)<\/a>', flags=re.A)

View File

@ -215,11 +215,14 @@ def sanitize(sanitized, edit=False):
tag['alt'] = f'![]({tag["data-src"]})'
tag['referrerpolicy'] = "no-referrer"
a = soup.new_tag("a", href=tag["data-src"], rel="nofollow noopener noreferrer")
tag = tag.replace_with(a)
a.append(tag)
if tag.parent.name != 'a':
a = soup.new_tag("a", href=tag["data-src"], rel="nofollow noopener noreferrer")
tag = tag.replace_with(a)
a.append(tag)
for tag in soup.find_all("a"):
if not tag.contents or not str(tag.contents[0]).strip():
tag.extract()
if tag.get("href") and fishylinks_regex.fullmatch(str(tag.string)):
tag.string = tag["href"]

View File

@ -1135,9 +1135,10 @@ def submit_post(v, sub=None):
gevent.spawn(archiveorg, newposturl)
captured = []
for i in list(snappy_url_regex.finditer(post.body_html)):
if i.group(0) in captured: continue
captured.append(i.group(0))
body_for_snappy = post.body_html.replace(' data-src="', ' src="')
for i in list(snappy_url_regex.finditer(body_for_snappy)):
if i.group(1) in captured: continue
captured.append(i.group(1))
href = i.group(1)
if not href: continue

View File

@ -70,7 +70,7 @@
{% endif %}
{% if p.award_count("firework", v) %}
<script defer src="/assets/js/fireworks.js?v=17"></script>
<script defer src="/assets/js/fireworks.js?v=18"></script>
<div class="firework">
<img src="">
</div>