From bb59cd047696d274df55fa839fd96a8a5e0087d7 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Sun, 10 Jul 2022 16:21:16 +0200 Subject: [PATCH] minor logic tweaks --- files/helpers/const.py | 2 +- files/routes/errors.py | 2 +- files/routes/posts.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/files/helpers/const.py b/files/helpers/const.py index 8af8d749b..8535657dc 100644 --- a/files/helpers/const.py +++ b/files/helpers/const.py @@ -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 diff --git a/files/routes/errors.py b/files/routes/errors.py index 1357de3c6..a0d5191a6 100644 --- a/files/routes/errors.py +++ b/files/routes/errors.py @@ -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('/') \ No newline at end of file diff --git a/files/routes/posts.py b/files/routes/posts.py index 2d6b265f5..1ea268553 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -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)