summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authoramalia <amalia.soucek@gmail.com>2017-02-10 09:30:51 +0100
committerTim Graham <timograham@gmail.com>2017-02-13 16:43:23 -0500
commitb54fff293846d24b3345a86fea223c93926e0c86 (patch)
treedf04da252380de77b3329e21e89274c93f45af80 /django
parentc0916144502b2b9d75b75ce6b01148aaa3dcaf68 (diff)
[1.11.x] Fixed #27820 -- Fixed RequestDataTooBig/TooManyFieldsSent crash.
Backport of 2f10216f84b55920de25422842a66260219e393f from master
Diffstat (limited to 'django')
-rw-r--r--django/core/handlers/exception.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/django/core/handlers/exception.py b/django/core/handlers/exception.py
index f1c7b57891..48324372b4 100644
--- a/django/core/handlers/exception.py
+++ b/django/core/handlers/exception.py
@@ -7,7 +7,10 @@ from functools import wraps
from django.conf import settings
from django.core import signals
-from django.core.exceptions import PermissionDenied, SuspiciousOperation
+from django.core.exceptions import (
+ PermissionDenied, RequestDataTooBig, SuspiciousOperation,
+ TooManyFieldsSent,
+)
from django.http import Http404
from django.http.multipartparser import MultiPartParserError
from django.urls import get_resolver, get_urlconf
@@ -64,6 +67,11 @@ def response_for_exception(request, exc):
response = get_exception_response(request, get_resolver(get_urlconf()), 400, exc)
elif isinstance(exc, SuspiciousOperation):
+ if isinstance(exc, (RequestDataTooBig, TooManyFieldsSent)):
+ # POST data can't be accessed again, otherwise the original
+ # exception would be raised.
+ request._mark_post_parse_error()
+
# The request logger receives events for any problematic request
# The security logger receives events for all SuspiciousOperations
security_logger = logging.getLogger('django.security.%s' % exc.__class__.__name__)