remotes/1693045480750635534/spooky-22
Aevann1 2022-04-17 00:42:12 +02:00
parent c9883f28c0
commit 39c374a90d
4 changed files with 26 additions and 28 deletions

View File

@ -710,11 +710,11 @@ fishylinks_regex = re.compile("https?://\S+", flags=re.A)
spoiler_regex = re.compile('''\|\|(.+)\|\|''', flags=re.A)
video_regex = re.compile('<p><a href="(https:\/\/[\w\-.#&/=\?@%;+]{5,250}\.(mp4|webm|mov))" rel="nofollow noopener noreferrer" target="_blank">(https:\/\/[\w\-.#&/=\?@%;+]{5,250}\.(mp4|webm|mov))<\/a><\/p>', flags=re.I|re.A)
unlinked_regex = re.compile('''(^|\s|<p>)(https:\/\/[\w\-.#&/=\?@%;+]{5,250})''', flags=re.A)
imgur_regex = re.compile('(https://i\.imgur\.com/([a-z0-9]+))\.(jpg|png|jpeg|webp)(?!</code>)', flags=re.I|re.A)
imgur_regex = re.compile('(https://i\.imgur\.com/([a-z0-9]+))\.(jpg|png|jpeg|webp)(?!</(code|pre)>)', flags=re.I|re.A)
reddit_regex = re.compile('(^|\s|<p>)\/?((r|u)\/(\w|-){3,25})', flags=re.A)
sub_regex = re.compile('(^|\s|<p>)\/?(h\/(\w|-){3,25})', flags=re.A)
youtube_regex = re.compile('(?<!<code>)https:\/\/youtube\.com\/watch\?v\=([a-z0-9-_]{5,20})[\w\-.#&/=\?@%+]*', flags=re.I|re.A)
youtube_regex = re.compile('(?<!<(code|pre)>)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)

View File

@ -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)

View File

@ -169,7 +169,7 @@
{% if request.host != 'pcmemes.net' %}
<a class="dropdown-item" href="/discord"><i class="fab fa-discord fa-fw mr-3"></i>Discord</a>
{% endif %}
{% if not (g.webview and v.truecoins < 1) %}
{% if not (g.webview and v.truecoins < 1) and SITE_NAME != 'Cringetopia' %}
<a class="dropdown-item" rel="nofollow noopener noreferrer" href="{{config('GUMROAD_LINK')}}"><i class="fas fa-dollar-sign fa-fw mr-3"></i>Donate</a>
{% endif %}
{% if SITE_NAME == 'rDrama' %}<a class="dropdown-item" href="/archives"><i class="fas fa-book fa-fw mr-3"></i>Archives</a>{% endif %}
@ -229,7 +229,7 @@
{% if request.host != 'pcmemes.net' %}
<a class="nav-item nav-link" href="/discord"><i class="fab fa-discord fa-fw mr-3"></i>Discord</a>
{% endif %}
{% if not (g.webview and v.truecoins < 1) %}
{% if not (g.webview and v.truecoins < 1) and SITE_NAME != 'Cringetopia' %}
<a class="nav-item nav-link" rel="nofollow noopener noreferrer" href="{{config('GUMROAD_LINK')}}"><i class="fas fa-dollar-sign fa-fw mr-3"></i>Donate</a>
{% endif %}
{% if SITE_NAME == 'rDrama' %}<a class="nav-item nav-link" href="/archives"><i class="fas fa-book fa-fw mr-3"></i>Archives</a>{% endif %}

View File

@ -42,19 +42,21 @@
</div>
<small id="emailpasswordRequired" class="form-text font-weight-bold text-danger d-none mt-1">Password required to update your email.</small>
</div>
<div class="footer">
<div class="d-flex">
<a class="btn btn-success" role="button" onclick="post_toast(this,'/settings/gumroad')">Claim paypig rewards</a>
{% if v.email %}
<input autocomplete="off" class="btn btn-primary ml-auto"
type="submit" value="Update email">
{% else %}
<input autocomplete="off" class="btn btn-primary ml-auto"
type="submit" value="Add email">
{% endif %}
{% if SITE_NAME != 'Cringetopia' %}
<div class="footer">
<div class="d-flex">
<a class="btn btn-success" role="button" onclick="post_toast(this,'/settings/gumroad')">Claim paypig rewards</a>
{% if v.email %}
<input autocomplete="off" class="btn btn-primary ml-auto"
type="submit" value="Update email">
{% else %}
<input autocomplete="off" class="btn btn-primary ml-auto"
type="submit" value="Add email">
{% endif %}
</div>
<span class="text-small-extra text-muted pl-1">Must be same email as gumroad</span>
</div>
<span class="text-small-extra text-muted pl-1">Must be same email as gumroad</span>
</div>
{% endif %}
</form>
</div>