diff options
| author | Virtosu Bogdan <virtosu.bogdan@gmail.com> | 2021-07-23 12:26:22 +0200 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2021-07-23 13:10:41 +0200 |
| commit | 00ea883ef56fb5e092cbe4a6f7ff2e7470886ac4 (patch) | |
| tree | f3ac2d410b8fa12ef8bd19d38e3de38984327bf2 /django/middleware/csrf.py | |
| parent | 852fa7617e24a68a990eaf0f7a597edb434ffd76 (diff) | |
Fixed #32329 -- Made CsrfViewMiddleware catch more specific UnreadablePostError.
Thanks Chris Jerdonek for the review.
Diffstat (limited to 'django/middleware/csrf.py')
| -rw-r--r-- | django/middleware/csrf.py | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/django/middleware/csrf.py b/django/middleware/csrf.py index d103900bdf..f8b8cf1ca0 100644 --- a/django/middleware/csrf.py +++ b/django/middleware/csrf.py @@ -11,6 +11,7 @@ from urllib.parse import urlparse from django.conf import settings from django.core.exceptions import DisallowedHost, ImproperlyConfigured +from django.http import UnreadablePostError from django.http.request import HttpHeaders from django.urls import get_callable from django.utils.cache import patch_vary_headers @@ -342,7 +343,7 @@ class CsrfViewMiddleware(MiddlewareMixin): if request.method == 'POST': try: request_csrf_token = request.POST.get('csrfmiddlewaretoken', '') - except OSError: + except UnreadablePostError: # Handle a broken connection before we've completed reading the # POST data. process_view shouldn't raise any exceptions, so # we'll ignore and serve the user a 403 (assuming they're still |
