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
8ec7ded3
Kaydet (Commit)
8ec7ded3
authored
Mar 01, 2019
tarafından
Tim Graham
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Refs #30227 -- Added helpful message for non-ASCII Content-Type in mulitpart request.
üst
2ed2acf8
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
1 deletion
+15
-1
multipartparser.py
django/http/multipartparser.py
+4
-1
tests.py
tests/requests/tests.py
+11
-0
No files found.
django/http/multipartparser.py
Dosyayı görüntüle @
8ec7ded3
...
@@ -67,7 +67,10 @@ class MultiPartParser:
...
@@ -67,7 +67,10 @@ class MultiPartParser:
raise
MultiPartParserError
(
'Invalid Content-Type:
%
s'
%
content_type
)
raise
MultiPartParserError
(
'Invalid Content-Type:
%
s'
%
content_type
)
# Parse the header to get the boundary to split the parts.
# Parse the header to get the boundary to split the parts.
ctypes
,
opts
=
parse_header
(
content_type
.
encode
(
'ascii'
))
try
:
ctypes
,
opts
=
parse_header
(
content_type
.
encode
(
'ascii'
))
except
UnicodeEncodeError
:
raise
MultiPartParserError
(
'Invalid non-ASCII Content-Type in multipart:
%
s'
%
force_str
(
content_type
))
boundary
=
opts
.
get
(
'boundary'
)
boundary
=
opts
.
get
(
'boundary'
)
if
not
boundary
or
not
cgi
.
valid_boundary
(
boundary
):
if
not
boundary
or
not
cgi
.
valid_boundary
(
boundary
):
raise
MultiPartParserError
(
'Invalid boundary in multipart:
%
s'
%
force_str
(
boundary
))
raise
MultiPartParserError
(
'Invalid boundary in multipart:
%
s'
%
force_str
(
boundary
))
...
...
tests/requests/tests.py
Dosyayı görüntüle @
8ec7ded3
...
@@ -487,6 +487,17 @@ class RequestsTests(SimpleTestCase):
...
@@ -487,6 +487,17 @@ class RequestsTests(SimpleTestCase):
with
self
.
assertRaisesMessage
(
MultiPartParserError
,
'Invalid boundary in multipart: None'
):
with
self
.
assertRaisesMessage
(
MultiPartParserError
,
'Invalid boundary in multipart: None'
):
request
.
POST
request
.
POST
def
test_multipart_non_ascii_content_type
(
self
):
request
=
WSGIRequest
({
'REQUEST_METHOD'
:
'POST'
,
'CONTENT_TYPE'
:
'multipart/form-data; boundary =
\xe0
'
,
'CONTENT_LENGTH'
:
0
,
'wsgi.input'
:
FakePayload
(),
})
msg
=
'Invalid non-ASCII Content-Type in multipart: multipart/form-data; boundary = à'
with
self
.
assertRaisesMessage
(
MultiPartParserError
,
msg
):
request
.
POST
def
test_POST_connection_error
(
self
):
def
test_POST_connection_error
(
self
):
"""
"""
If wsgi.input.read() raises an exception while trying to read() the
If wsgi.input.read() raises an exception while trying to read() the
...
...
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