Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
D
django
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
django
Commits
2f10216f
Kaydet (Commit)
2f10216f
authored
Şub 10, 2017
tarafından
amalia
Kaydeden (comit)
Tim Graham
Şub 13, 2017
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #27820 -- Fixed RequestDataTooBig/TooManyFieldsSent crash.
üst
3effe3a9
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
39 additions
and
1 deletion
+39
-1
exception.py
django/core/handlers/exception.py
+9
-1
1.10.6.txt
docs/releases/1.10.6.txt
+3
-0
test_exception.py
tests/handlers/test_exception.py
+27
-0
No files found.
django/core/handlers/exception.py
Dosyayı görüntüle @
2f10216f
...
...
@@ -4,7 +4,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
...
...
@@ -59,6 +62,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__
)
...
...
docs/releases/1.10.6.txt
Dosyayı görüntüle @
2f10216f
...
...
@@ -11,3 +11,6 @@ Bugfixes
* Fixed ``ClearableFileInput``’s "Clear" checkbox on model form fields where
the model field has a ``default`` (:ticket:`27805`).
* Fixed ``RequestDataTooBig`` and ``TooManyFieldsSent`` exceptions crashing
rather than generating a bad request response (:ticket:`27820`).
tests/handlers/test_exception.py
0 → 100644
Dosyayı görüntüle @
2f10216f
from
django.core.handlers.wsgi
import
WSGIHandler
from
django.test
import
SimpleTestCase
,
override_settings
from
django.test.client
import
FakePayload
class
ExceptionHandlerTests
(
SimpleTestCase
):
def
get_suspicious_environ
(
self
):
payload
=
FakePayload
(
'a=1&a=2;a=3
\r\n
'
)
return
{
'REQUEST_METHOD'
:
'POST'
,
'CONTENT_TYPE'
:
'application/x-www-form-urlencoded'
,
'CONTENT_LENGTH'
:
len
(
payload
),
'wsgi.input'
:
payload
,
'SERVER_NAME'
:
'test'
,
'SERVER_PORT'
:
'8000'
,
}
@override_settings
(
DATA_UPLOAD_MAX_MEMORY_SIZE
=
12
)
def
test_data_upload_max_memory_size_exceeded
(
self
):
response
=
WSGIHandler
()(
self
.
get_suspicious_environ
(),
lambda
*
a
,
**
k
:
None
)
self
.
assertEqual
(
response
.
status_code
,
400
)
@override_settings
(
DATA_UPLOAD_MAX_NUMBER_FIELDS
=
2
)
def
test_data_upload_max_number_fields_exceeded
(
self
):
response
=
WSGIHandler
()(
self
.
get_suspicious_environ
(),
lambda
*
a
,
**
k
:
None
)
self
.
assertEqual
(
response
.
status_code
,
400
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment