Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
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
cpython
Commits
096f1a85
Kaydet (Commit)
096f1a85
authored
Mar 01, 2011
tarafından
Victor Stinner
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #10911: Add tests on CGI with non-ASCII characters
Patch written by Pierre Quentel
üst
819c40ff
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
54 additions
and
24 deletions
+54
-24
test_cgi.py
Lib/test/test_cgi.py
+51
-24
NEWS
Misc/NEWS
+3
-0
No files found.
Lib/test/test_cgi.py
Dosyayı görüntüle @
096f1a85
...
@@ -197,30 +197,12 @@ class CgiTests(unittest.TestCase):
...
@@ -197,30 +197,12 @@ class CgiTests(unittest.TestCase):
def
test_fieldstorage_multipart
(
self
):
def
test_fieldstorage_multipart
(
self
):
#Test basic FieldStorage multipart parsing
#Test basic FieldStorage multipart parsing
env
=
{
'REQUEST_METHOD'
:
'POST'
,
'CONTENT_TYPE'
:
'multipart/form-data; boundary=---------------------------721837373350705526688164684'
,
'CONTENT_LENGTH'
:
'558'
}
env
=
{
postdata
=
"""-----------------------------721837373350705526688164684
'REQUEST_METHOD'
:
'POST'
,
Content-Disposition: form-data; name="id"
'CONTENT_TYPE'
:
'multipart/form-data; boundary={}'
.
format
(
BOUNDARY
),
'CONTENT_LENGTH'
:
'558'
}
1234
fp
=
BytesIO
(
POSTDATA
.
encode
(
'latin-1'
))
-----------------------------721837373350705526688164684
fs
=
cgi
.
FieldStorage
(
fp
,
environ
=
env
,
encoding
=
"latin-1"
)
Content-Disposition: form-data; name="title"
-----------------------------721837373350705526688164684
Content-Disposition: form-data; name="file"; filename="test.txt"
Content-Type: text/plain
Testing 123.
-----------------------------721837373350705526688164684
Content-Disposition: form-data; name="submit"
Add
\x20
-----------------------------721837373350705526688164684--
"""
encoding
=
'ascii'
fp
=
BytesIO
(
postdata
.
encode
(
encoding
))
fs
=
cgi
.
FieldStorage
(
fp
,
environ
=
env
,
encoding
=
encoding
)
self
.
assertEqual
(
len
(
fs
.
list
),
4
)
self
.
assertEqual
(
len
(
fs
.
list
),
4
)
expect
=
[{
'name'
:
'id'
,
'filename'
:
None
,
'value'
:
'1234'
},
expect
=
[{
'name'
:
'id'
,
'filename'
:
None
,
'value'
:
'1234'
},
{
'name'
:
'title'
,
'filename'
:
None
,
'value'
:
''
},
{
'name'
:
'title'
,
'filename'
:
None
,
'value'
:
''
},
...
@@ -231,6 +213,21 @@ Content-Disposition: form-data; name="submit"
...
@@ -231,6 +213,21 @@ Content-Disposition: form-data; name="submit"
got
=
getattr
(
fs
.
list
[
x
],
k
)
got
=
getattr
(
fs
.
list
[
x
],
k
)
self
.
assertEqual
(
got
,
exp
)
self
.
assertEqual
(
got
,
exp
)
def
test_fieldstorage_multipart_non_ascii
(
self
):
#Test basic FieldStorage multipart parsing
env
=
{
'REQUEST_METHOD'
:
'POST'
,
'CONTENT_TYPE'
:
'multipart/form-data; boundary={}'
.
format
(
BOUNDARY
),
'CONTENT_LENGTH'
:
'558'
}
for
encoding
in
[
'iso-8859-1'
,
'utf-8'
]:
fp
=
BytesIO
(
POSTDATA_NON_ASCII
.
encode
(
encoding
))
fs
=
cgi
.
FieldStorage
(
fp
,
environ
=
env
,
encoding
=
encoding
)
self
.
assertEqual
(
len
(
fs
.
list
),
1
)
expect
=
[{
'name'
:
'id'
,
'filename'
:
None
,
'value'
:
'
\xe7\xf1\x80
'
}]
for
x
in
range
(
len
(
fs
.
list
)):
for
k
,
exp
in
expect
[
x
]
.
items
():
got
=
getattr
(
fs
.
list
[
x
],
k
)
self
.
assertEqual
(
got
,
exp
)
_qs_result
=
{
_qs_result
=
{
'key1'
:
'value1'
,
'key1'
:
'value1'
,
'key2'
:
[
'value2x'
,
'value2y'
],
'key2'
:
[
'value2x'
,
'value2y'
],
...
@@ -346,6 +343,36 @@ this is the content of the fake file
...
@@ -346,6 +343,36 @@ this is the content of the fake file
cgi
.
parse_header
(
'attachment; filename="strange;name";size=123;'
),
cgi
.
parse_header
(
'attachment; filename="strange;name";size=123;'
),
(
"attachment"
,
{
"filename"
:
"strange;name"
,
"size"
:
"123"
}))
(
"attachment"
,
{
"filename"
:
"strange;name"
,
"size"
:
"123"
}))
BOUNDARY
=
"---------------------------721837373350705526688164684"
POSTDATA
=
"""-----------------------------721837373350705526688164684
Content-Disposition: form-data; name="id"
1234
-----------------------------721837373350705526688164684
Content-Disposition: form-data; name="title"
-----------------------------721837373350705526688164684
Content-Disposition: form-data; name="file"; filename="test.txt"
Content-Type: text/plain
Testing 123.
-----------------------------721837373350705526688164684
Content-Disposition: form-data; name="submit"
Add
\x20
-----------------------------721837373350705526688164684--
"""
POSTDATA_NON_ASCII
=
"""-----------------------------721837373350705526688164684
Content-Disposition: form-data; name="id"
\xe7\xf1\x80
-----------------------------721837373350705526688164684
"""
def
test_main
():
def
test_main
():
run_unittest
(
CgiTests
)
run_unittest
(
CgiTests
)
...
...
Misc/NEWS
Dosyayı görüntüle @
096f1a85
...
@@ -122,6 +122,9 @@ Build
...
@@ -122,6 +122,9 @@ Build
Tests
Tests
-----
-----
- Issue #10911: Add tests on CGI with non-ASCII characters. Patch written by
Pierre Quentel.
- Issue #9931: Fix hangs in GUI tests under Windows in certain conditions.
- Issue #9931: Fix hangs in GUI tests under Windows in certain conditions.
Patch by Hirokazu Yamamoto.
Patch by Hirokazu Yamamoto.
...
...
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