minor logic tweaks

remotes/1693045480750635534/spooky-22
Aevann1 2022-07-10 16:21:16 +02:00
parent 0b7a5208e9
commit bb59cd0476
3 changed files with 3 additions and 3 deletions

View File

@ -960,7 +960,7 @@ approved_embed_hosts = {
def is_site_url(url):
return '\\' not in url and (url.startswith('/') or url.startswith(f'{SITE_FULL}/'))
return url and '\\' not in url and (url.startswith('/') or url.startswith(f'{SITE_FULL}/'))
def is_safe_url(url):
return is_site_url(url) or tldextract.extract(url).registered_domain in approved_embed_hosts

View File

@ -80,5 +80,5 @@ def error_500(e):
def allow_nsfw():
session["over_18"] = int(time.time()) + 3600
redir = request.values.get("redir")
if redir and is_site_url(redir): return redirect(redir)
if is_site_url(redir): return redirect(redir)
return redirect('/')

View File

@ -74,7 +74,7 @@ def publish(pid, v):
execute_snappy(post, v)
if request.referrer and request.referrer.startswith(f'{SITE_FULL}/'):
if is_site_url(request.referrer):
return redirect(request.referrer)
return redirect(post.permalink)