fix snappy archiving images

master
Aevann1 2022-07-02 02:25:58 +02:00
parent 100677c1bb
commit 28786342dc
2 changed files with 8 additions and 6 deletions

View File

@ -215,6 +215,7 @@ def sanitize(sanitized, edit=False):
tag['alt'] = f'![]({tag["data-src"]})'
tag['referrerpolicy'] = "no-referrer"
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)

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