summaryrefslogtreecommitdiff
path: root/pgweb/util/helpers.py
diff options
context:
space:
mode:
authorMagnus Hagander2017-02-26 15:09:36 +0000
committerMagnus Hagander2017-02-26 15:09:36 +0000
commite631ebbc37d1aeb21184d1ff2dbf7eab588decfa (patch)
tree9b209909276edc764dd021a873d185d14ff4ae52 /pgweb/util/helpers.py
parentce5fa507bee5ab3d8af1390f1a45d6a46ec6fb85 (diff)
Trap invalid URLs for submission forms
I still haven't figured out where these come from, but generate a proper 404 when the URL is malformatted rather than trying to render it and crash with an exception
Diffstat (limited to 'pgweb/util/helpers.py')
-rw-r--r--pgweb/util/helpers.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/pgweb/util/helpers.py b/pgweb/util/helpers.py
index 71134bd2..a203b0ef 100644
--- a/pgweb/util/helpers.py
+++ b/pgweb/util/helpers.py
@@ -1,6 +1,6 @@
from django.shortcuts import render_to_response, get_object_or_404
from pgweb.util.contexts import NavContext
-from django.http import HttpResponseRedirect
+from django.http import HttpResponseRedirect, Http404
from django.template import Context
from django.template.loader import get_template
import django.utils.xmlutils
@@ -10,6 +10,10 @@ def simple_form(instancetype, itemid, request, formclass, formtemplate='base/for
instance = instancetype()
else:
# Regular form item, attempt to edit it
+ try:
+ i = int(itemid)
+ except ValueError:
+ raise Http404("Invalid URL")
if createifempty:
(instance, wascreated) = instancetype.objects.get_or_create(pk=itemid)
else: