dffsd
This commit is contained in:
parent
59d55da7ba
commit
a0776a29ce
1 changed files with 5 additions and 16 deletions
|
@ -131,8 +131,8 @@ def sanitize(sanitized, noimages=False):
|
||||||
if "profile-pic-20" not in tag.get("class", ""):
|
if "profile-pic-20" not in tag.get("class", ""):
|
||||||
|
|
||||||
tag["rel"] = "nofollow noopener noreferrer"
|
tag["rel"] = "nofollow noopener noreferrer"
|
||||||
tag["style"] = "max-height: 100px; max-width: 100%;"
|
tag["height"] = "200px"
|
||||||
tag["class"] = "in-comment-image rounded-sm my-2"
|
tag["class"] = "rounded-sm my-2"
|
||||||
tag["loading"] = "lazy"
|
tag["loading"] = "lazy"
|
||||||
tag["data-src"] = tag["src"]
|
tag["data-src"] = tag["src"]
|
||||||
tag["src"] = ""
|
tag["src"] = ""
|
||||||
|
@ -148,28 +148,18 @@ def sanitize(sanitized, noimages=False):
|
||||||
|
|
||||||
tag.wrap(link)
|
tag.wrap(link)
|
||||||
|
|
||||||
#disguised link preventer
|
|
||||||
for tag in soup.find_all("a"):
|
for tag in soup.find_all("a"):
|
||||||
|
|
||||||
tag["target"] = "_blank"
|
tag["target"] = "_blank"
|
||||||
if site not in tag["href"]: tag["rel"] = "nofollow noopener noreferrer"
|
if site not in tag["href"]: tag["rel"] = "nofollow noopener noreferrer"
|
||||||
|
|
||||||
if re.match("https?://\S+", str(tag.string)):
|
if re.match("https?://\S+", str(tag.string)):
|
||||||
try:
|
try: tag.string = tag["href"]
|
||||||
tag.string = tag["href"]
|
except: tag.string = ""
|
||||||
except:
|
|
||||||
tag.string = ""
|
|
||||||
|
|
||||||
#clean up tags in code
|
|
||||||
for tag in soup.find_all("code"):
|
for tag in soup.find_all("code"):
|
||||||
tag.contents=[x.string for x in tag.contents if x.string]
|
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"):
|
for tag in soup.find_all("table"):
|
||||||
tag.attrs['class']="table table-striped"
|
tag.attrs['class']="table table-striped"
|
||||||
|
|
||||||
|
@ -185,8 +175,7 @@ def sanitize(sanitized, noimages=False):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if not session.get("favorite_emojis"): session["favorite_emojis"] = {}
|
if not session.get("favorite_emojis"): session["favorite_emojis"] = {}
|
||||||
except:
|
except: pass
|
||||||
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>')
|
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>')
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue