better solution to the transform question

master
Aevann 2023-09-22 09:51:45 +03:00
parent 2a31e8a841
commit 1649879a69
1 changed files with 4 additions and 4 deletions

View File

@ -582,6 +582,8 @@ def sanitize(sanitized, golden=True, limit_pings=0, showmore=False, count_emojis
#doing this here cuz of the linkifyfilter right above it (therefore unifying all link processing logic) #doing this here cuz of the linkifyfilter right above it (therefore unifying all link processing logic)
soup = BeautifulSoup(sanitized, 'lxml') soup = BeautifulSoup(sanitized, 'lxml')
has_transform = bool(soup.select('[style*=transform]'))
links = soup.find_all("a") links = soup.find_all("a")
if g.v and g.v.admin_level >= PERMS["IGNORE_DOMAIN_BAN"]: if g.v and g.v.admin_level >= PERMS["IGNORE_DOMAIN_BAN"]:
@ -645,10 +647,8 @@ def sanitize(sanitized, golden=True, limit_pings=0, showmore=False, count_emojis
link["target"] = "_blank" link["target"] = "_blank"
link["rel"] = "nofollow noopener" link["rel"] = "nofollow noopener"
for child in link.findChildren(): if has_transform:
if 'transform' in child.get("style", "").lower(): del link["href"]
del link["href"]
break
sanitized = str(soup).replace('<html><body>','').replace('</body></html>','').replace('/>','>') sanitized = str(soup).replace('<html><body>','').replace('</body></html>','').replace('/>','>')