From af609a50bdd39c79b91021d5ae34d27b2e8b676e Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Thu, 7 Oct 2021 10:53:36 +0200 Subject: [PATCH] dffsd --- files/helpers/sanitize.py | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/files/helpers/sanitize.py b/files/helpers/sanitize.py index 8800a8614..be06e8c6b 100644 --- a/files/helpers/sanitize.py +++ b/files/helpers/sanitize.py @@ -131,8 +131,8 @@ def sanitize(sanitized, noimages=False): if "profile-pic-20" not in tag.get("class", ""): tag["rel"] = "nofollow noopener noreferrer" - tag["style"] = "max-height: 100px; max-width: 100%;" - tag["class"] = "in-comment-image rounded-sm my-2" + tag["height"] = "200px" + tag["class"] = "rounded-sm my-2" tag["loading"] = "lazy" tag["data-src"] = tag["src"] tag["src"] = "" @@ -148,28 +148,18 @@ 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" @@ -185,8 +175,7 @@ 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, '').replace(end, '')