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
74a146d3
Kaydet (Commit)
74a146d3
authored
Tem 07, 2013
tarafından
Florent Xicluna
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
Merge #18013: Fix cgi.FieldStorage to parse the W3C sample form.
üst
4603487d
331c3fd8
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
49 additions
and
1 deletion
+49
-1
cgi.py
Lib/cgi.py
+1
-1
test_cgi.py
Lib/test/test_cgi.py
+46
-0
NEWS
Misc/NEWS
+2
-0
No files found.
Lib/cgi.py
Dosyayı görüntüle @
74a146d3
...
@@ -699,7 +699,7 @@ class FieldStorage:
...
@@ -699,7 +699,7 @@ class FieldStorage:
self
.
encoding
,
self
.
errors
)
self
.
encoding
,
self
.
errors
)
self
.
bytes_read
+=
part
.
bytes_read
self
.
bytes_read
+=
part
.
bytes_read
self
.
list
.
append
(
part
)
self
.
list
.
append
(
part
)
if
self
.
bytes_read
>=
self
.
length
:
if
part
.
done
or
self
.
bytes_read
>=
self
.
length
>
0
:
break
break
self
.
skip_lines
()
self
.
skip_lines
()
...
...
Lib/test/test_cgi.py
Dosyayı görüntüle @
74a146d3
...
@@ -279,6 +279,27 @@ Content-Type: text/plain
...
@@ -279,6 +279,27 @@ Content-Type: text/plain
check
(
'x'
*
(
maxline
-
1
)
+
'
\r
'
)
check
(
'x'
*
(
maxline
-
1
)
+
'
\r
'
)
check
(
'x'
*
(
maxline
-
1
)
+
'
\r
'
+
'y'
*
(
maxline
-
1
))
check
(
'x'
*
(
maxline
-
1
)
+
'
\r
'
+
'y'
*
(
maxline
-
1
))
def
test_fieldstorage_multipart_w3c
(
self
):
# Test basic FieldStorage multipart parsing (W3C sample)
env
=
{
'REQUEST_METHOD'
:
'POST'
,
'CONTENT_TYPE'
:
'multipart/form-data; boundary={}'
.
format
(
BOUNDARY_W3
),
'CONTENT_LENGTH'
:
str
(
len
(
POSTDATA_W3
))}
fp
=
BytesIO
(
POSTDATA_W3
.
encode
(
'latin-1'
))
fs
=
cgi
.
FieldStorage
(
fp
,
environ
=
env
,
encoding
=
"latin-1"
)
self
.
assertEqual
(
len
(
fs
.
list
),
2
)
self
.
assertEqual
(
fs
.
list
[
0
]
.
name
,
'submit-name'
)
self
.
assertEqual
(
fs
.
list
[
0
]
.
value
,
'Larry'
)
self
.
assertEqual
(
fs
.
list
[
1
]
.
name
,
'files'
)
files
=
fs
.
list
[
1
]
.
value
self
.
assertEqual
(
len
(
files
),
2
)
expect
=
[{
'name'
:
None
,
'filename'
:
'file1.txt'
,
'value'
:
b
'... contents of file1.txt ...'
},
{
'name'
:
None
,
'filename'
:
'file2.gif'
,
'value'
:
b
'...contents of file2.gif...'
}]
for
x
in
range
(
len
(
files
)):
for
k
,
exp
in
expect
[
x
]
.
items
():
got
=
getattr
(
files
[
x
],
k
)
self
.
assertEqual
(
got
,
exp
)
_qs_result
=
{
_qs_result
=
{
'key1'
:
'value1'
,
'key1'
:
'value1'
,
'key2'
:
[
'value2x'
,
'value2y'
],
'key2'
:
[
'value2x'
,
'value2y'
],
...
@@ -428,6 +449,31 @@ Content-Disposition: form-data; name="id"
...
@@ -428,6 +449,31 @@ Content-Disposition: form-data; name="id"
-----------------------------721837373350705526688164684
-----------------------------721837373350705526688164684
"""
"""
# http://www.w3.org/TR/html401/interact/forms.html#h-17.13.4
BOUNDARY_W3
=
"AaB03x"
POSTDATA_W3
=
"""--AaB03x
Content-Disposition: form-data; name="submit-name"
Larry
--AaB03x
Content-Disposition: form-data; name="files"
Content-Type: multipart/mixed; boundary=BbC04y
--BbC04y
Content-Disposition: file; filename="file1.txt"
Content-Type: text/plain
... contents of file1.txt ...
--BbC04y
Content-Disposition: file; filename="file2.gif"
Content-Type: image/gif
Content-Transfer-Encoding: binary
...contents of file2.gif...
--BbC04y--
--AaB03x--
"""
def
test_main
():
def
test_main
():
run_unittest
(
CgiTests
)
run_unittest
(
CgiTests
)
...
...
Misc/NEWS
Dosyayı görüntüle @
74a146d3
...
@@ -142,6 +142,8 @@ Core and Builtins
...
@@ -142,6 +142,8 @@ Core and Builtins
Library
Library
-------
-------
-
Issue
#
18013
:
Fix
cgi
.
FieldStorage
to
parse
the
W3C
sample
form
.
-
Issue
#
18020
:
improve
html
.
escape
speed
by
an
order
of
magnitude
.
-
Issue
#
18020
:
improve
html
.
escape
speed
by
an
order
of
magnitude
.
Patch
by
Matt
Bryant
.
Patch
by
Matt
Bryant
.
...
...
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