Skip to content

Instantly share code, notes, and snippets.

@kinkerl
Last active August 29, 2015 14:16
Show Gist options
  • Save kinkerl/88f9015108185db8ddd8 to your computer and use it in GitHub Desktop.
Save kinkerl/88f9015108185db8ddd8 to your computer and use it in GitHub Desktop.
Django middleware to discard to long urls to prevent strange injections and errors with inferior databases
from django.http import Http404
class GracefullDiscardLongURLMiddleware:
def process_request(self, request): # pylint: disable-msg=R0201
if len(request.path) >= 255:
raise Http404
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment