From 154df1af2bdaf261cd459eaf2f1c630311150ae5 Mon Sep 17 00:00:00 2001 From: sqozz Date: Tue, 1 May 2018 03:53:11 +0200 Subject: [PATCH] Fix url input and mark it as required Validation is done in html on the client and raises an error 400 in the api. This fixes #2. --- schort.py | 2 ++ templates/index.html | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/schort.py b/schort.py index 9959773..4a0d6e4 100755 --- a/schort.py +++ b/schort.py @@ -38,6 +38,8 @@ def short(shortLink=""): 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 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 diff --git a/templates/index.html b/templates/index.html index 6004d31..ad3e6a1 100644 --- a/templates/index.html +++ b/templates/index.html @@ -12,7 +12,7 @@
URL: - +