This would already not work at a lower layer, but would typically
generate an internal server error exception instead of just an error
message.
Instead, put an explicit check in the middleware that's already
validating the query parameters and reject them with a 400 error.
from django.conf import settings
from django.http import QueryDict
+from django.core.exceptions import SuspiciousOperation
from pgweb.util.templateloader import initialize_template_collection, get_all_templates
for k in request.GET.keys():
if k not in allowed:
del result[k]
+ if "\0" in request.GET[k]:
+ raise SuspiciousOperation("NUL escapes not allowed in query parameters")
result.mutable = False
request.GET = result
else: