minor logic tweaks
parent
0b7a5208e9
commit
bb59cd0476
|
@ -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
|
||||
|
|
|
@ -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('/')
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue