mirror of
https://codeberg.org/rimu/pyfedi
synced 2025-01-23 19:36:56 -08:00
avoid wrapping anchors around existing anchors
(e.g. if raw URL already wrapped by remote PieFed instance)
This commit is contained in:
parent
bdb201f4d3
commit
646bcdf7be
1 changed files with 4 additions and 0 deletions
|
@ -284,6 +284,10 @@ def allowlist_html(html: str, a_target='_blank') -> str:
|
|||
|
||||
clean_html = str(soup)
|
||||
|
||||
# avoid wrapping anchors around existing anchors (e.g. if raw URL already wrapped by remote PieFed instance)
|
||||
re_double_anchor = re.compile(r'<a href=".*?" rel="nofollow ugc" target="_blank">(<a href=".*?" rel="nofollow ugc" target="_blank">.*?<\/a>)<\/a>')
|
||||
clean_html = re_double_anchor.sub(r'\1', clean_html)
|
||||
|
||||
# avoid returning empty anchors
|
||||
re_empty_anchor = re.compile(r'<a href="(.*?)" rel="nofollow ugc" target="_blank"><\/a>')
|
||||
clean_html = re_empty_anchor.sub(r'<a href="\1" rel="nofollow ugc" target="_blank">\1</a>', clean_html)
|
||||
|
|
Loading…
Reference in a new issue