aboutsummaryrefslogtreecommitdiff
path: root/app/utils.py
diff options
context:
space:
mode:
authorrubenwardy <rw@rubenwardy.com>2019-11-17 21:40:32 +0000
committerrubenwardy <rw@rubenwardy.com>2019-11-17 21:40:55 +0000
commit3f666d2302f5ad78784f2e8a8362134652eed4b9 (patch)
treedf3dadcfcec38db2eee4c89a03ccca145ca75d93 /app/utils.py
parenta7d22973ff12c6117e70fb0486c66bf510e62325 (diff)
downloadcheatdb-3f666d2302f5ad78784f2e8a8362134652eed4b9.tar.xz
Fix exception on badly-formed query string
Diffstat (limited to 'app/utils.py')
-rw-r--r--app/utils.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/app/utils.py b/app/utils.py
index fd36392..102219d 100644
--- a/app/utils.py
+++ b/app/utils.py
@@ -22,6 +22,12 @@ from app.models import *
from app import app
import random, string, os, imghdr
+def get_int_or_abort(v, default):
+ try:
+ return int(v or default)
+ except ValueError:
+ abort(400)
+
def getExtension(filename):
return filename.rsplit(".", 1)[1].lower() if "." in filename else None