dRevert "dffsd"

This reverts commit af609a50bd.
remotes/1693045480750635534/spooky-22
Aevann1 2021-10-07 23:10:40 +02:00
parent 7718bebfd8
commit 3dc9a13d32
1 changed files with 16 additions and 5 deletions

View File

@ -131,8 +131,8 @@ def sanitize(sanitized, noimages=False):
if "profile-pic-20" not in tag.get("class", ""):
tag["rel"] = "nofollow noopener noreferrer"
tag["height"] = "200px"
tag["class"] = "rounded-sm my-2"
tag["style"] = "max-height: 100px; max-width: 100%;"
tag["class"] = "in-comment-image rounded-sm my-2"
tag["loading"] = "lazy"
tag["data-src"] = tag["src"]
tag["src"] = ""
@ -148,18 +148,28 @@ def sanitize(sanitized, noimages=False):
tag.wrap(link)
#disguised link preventer
for tag in soup.find_all("a"):
tag["target"] = "_blank"
if site not in tag["href"]: tag["rel"] = "nofollow noopener noreferrer"
if re.match("https?://\S+", str(tag.string)):
try: tag.string = tag["href"]
except: tag.string = ""
try:
tag.string = tag["href"]
except:
tag.string = ""
#clean up tags in code
for tag in soup.find_all("code"):
tag.contents=[x.string for x in tag.contents if x.string]
#whatever else happens with images, there are only two sets of classes allowed
for tag in soup.find_all("img"):
if 'profile-pic-20' not in tag.attrs.get("class",""):
tag.attrs['class']="in-comment-image rounded-sm my-2"
#table format
for tag in soup.find_all("table"):
tag.attrs['class']="table table-striped"
@ -175,7 +185,8 @@ def sanitize(sanitized, noimages=False):
try:
if not session.get("favorite_emojis"): session["favorite_emojis"] = {}
except: pass
except:
pass
if start in sanitized and end in sanitized and start in sanitized.split(end)[0] and end in sanitized.split(start)[1]: sanitized = sanitized.replace(start, '<span class="spoiler">').replace(end, '</span>')