From eda9cae66771bc121c258a49a9a94650709a2b78 Mon Sep 17 00:00:00 2001 From: sqozz Date: Sat, 9 Jun 2018 21:57:17 +0200 Subject: [PATCH] Fix handling of empty requests --- schort.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/schort.py b/schort.py index 4a0d6e4..fed98d4 100755 --- a/schort.py +++ b/schort.py @@ -36,10 +36,11 @@ def short(shortLink=""): else: return render_template("index.html", name=shortLink) # Landing page elif request.method == "POST": # Someone submitted a new link to short - longUrl = request.form["url"] # required, accept the exception if the key does not exist + longUrl = request.form.get("url", "") wishId = request.form.get("wishId") if len(longUrl) <= 0: abort(400) + databaseId = insertIdUnique(longUrl, idToCheck=wishId) return request.url_root + databaseId # Short link in plain text