diff --git a/files/helpers/const.py b/files/helpers/const.py index 3f9c036d8..59d20d641 100644 --- a/files/helpers/const.py +++ b/files/helpers/const.py @@ -710,11 +710,11 @@ fishylinks_regex = re.compile("https?://\S+", flags=re.A) spoiler_regex = re.compile('''\|\|(.+)\|\|''', flags=re.A) video_regex = re.compile('

(https:\/\/[\w\-.#&/=\?@%;+]{5,250}\.(mp4|webm|mov))<\/a><\/p>', flags=re.I|re.A) unlinked_regex = re.compile('''(^|\s|

)(https:\/\/[\w\-.#&/=\?@%;+]{5,250})''', flags=re.A) -imgur_regex = re.compile('(https://i\.imgur\.com/([a-z0-9]+))\.(jpg|png|jpeg|webp)(?!)', flags=re.I|re.A) +imgur_regex = re.compile('(https://i\.imgur\.com/([a-z0-9]+))\.(jpg|png|jpeg|webp)(?!)', flags=re.I|re.A) reddit_regex = re.compile('(^|\s|

)\/?((r|u)\/(\w|-){3,25})', flags=re.A) sub_regex = re.compile('(^|\s|

)\/?(h\/(\w|-){3,25})', flags=re.A) -youtube_regex = re.compile('(?)https:\/\/youtube\.com\/watch\?v\=([a-z0-9-_]{5,20})[\w\-.#&/=\?@%+]*', flags=re.I|re.A) +youtube_regex = re.compile('(?)https:\/\/youtube\.com\/watch\?v\=([a-z0-9-_]{5,20})[\w\-.#&/=\?@%+]*', flags=re.I|re.A) yt_id_regex = re.compile('[a-z0-9-_]{5,20}', flags=re.I|re.A) strikethrough_regex = re.compile('''~{1,2}([^~]+)~{1,2}''', flags=re.A) diff --git a/files/helpers/sanitize.py b/files/helpers/sanitize.py index 142036a83..a8bf06b62 100644 --- a/files/helpers/sanitize.py +++ b/files/helpers/sanitize.py @@ -68,18 +68,6 @@ def sanitize(sanitized, noimages=False, alert=False, comment=False, edit=False): tag['alt'] = f'![]({tag["data-src"]})' tag['referrerpolicy'] = "no-referrer" - for tag in soup.find_all("a"): - del tag["rel"] - if tag.get("href"): - if not tag["href"].startswith(SITE_FULL) and not tag["href"].startswith('/') and not tag["href"].startswith(SITE_FULL2): - tag["target"] = "_blank" - tag["rel"] = "nofollow noopener noreferrer" - - if fishylinks_regex.fullmatch(str(tag.string)): - try: tag.string = tag["href"] - except: tag.string = "" - - sanitized = str(soup) @@ -253,6 +241,14 @@ def sanitize(sanitized, noimages=False, alert=False, comment=False, edit=False): ).clean(sanitized) + for tag in soup.find_all("a"): + if tag.get("href"): + if not tag["href"].startswith(SITE_FULL) and not tag["href"].startswith('/') and not tag["href"].startswith(SITE_FULL2): + tag["target"] = "_blank" + tag["rel"] = "nofollow noopener noreferrer" + + if fishylinks_regex.fullmatch(str(tag.string)): tag.string = tag["href"] + signal.alarm(0) diff --git a/files/templates/header.html b/files/templates/header.html index 43526cc90..613462e0d 100644 --- a/files/templates/header.html +++ b/files/templates/header.html @@ -169,7 +169,7 @@ {% if request.host != 'pcmemes.net' %} Discord {% endif %} - {% if not (g.webview and v.truecoins < 1) %} + {% if not (g.webview and v.truecoins < 1) and SITE_NAME != 'Cringetopia' %} Donate {% endif %} {% if SITE_NAME == 'rDrama' %}Archives{% endif %} @@ -229,7 +229,7 @@ {% if request.host != 'pcmemes.net' %} Discord {% endif %} - {% if not (g.webview and v.truecoins < 1) %} + {% if not (g.webview and v.truecoins < 1) and SITE_NAME != 'Cringetopia' %} Donate {% endif %} {% if SITE_NAME == 'rDrama' %}Archives{% endif %} diff --git a/files/templates/settings_security.html b/files/templates/settings_security.html index 4f9f57522..b3826ea7e 100644 --- a/files/templates/settings_security.html +++ b/files/templates/settings_security.html @@ -42,19 +42,21 @@ Password required to update your email. -