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
e1b13d20
Kaydet (Commit)
e1b13d20
authored
Agu 24, 2005
tarafından
Georg Brandl
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Bug #735248: Fix urllib2.parse_http_list.
üst
256372c8
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
38 deletions
+43
-38
test_urllib2.py
Lib/test/test_urllib2.py
+8
-0
urllib2.py
Lib/urllib2.py
+35
-38
No files found.
Lib/test/test_urllib2.py
Dosyayı görüntüle @
e1b13d20
...
@@ -45,6 +45,14 @@ class TrivialTests(unittest.TestCase):
...
@@ -45,6 +45,14 @@ class TrivialTests(unittest.TestCase):
# test the new-in-2.5 httpresponses dictionary
# test the new-in-2.5 httpresponses dictionary
self
.
assertEquals
(
urllib2
.
httpresponses
[
404
],
"Not Found"
)
self
.
assertEquals
(
urllib2
.
httpresponses
[
404
],
"Not Found"
)
def
test_parse_http_list
(
self
):
tests
=
[(
'a,b,c'
,
[
'a'
,
'b'
,
'c'
]),
(
'path"o,l"og"i"cal, example'
,
[
'path"o,l"og"i"cal'
,
'example'
]),
(
'a, b, "c", "d", "e,f", g, h'
,
[
'a'
,
'b'
,
'"c"'
,
'"d"'
,
'"e,f"'
,
'g'
,
'h'
]),
(
'a="b
\\
"c", d="e
\\
,f", g="h
\\\\
i"'
,
[
'a="b"c"'
,
'd="e,f"'
,
'g="h
\\
i"'
])]
for
string
,
list
in
tests
:
self
.
assertEquals
(
urllib2
.
parse_http_list
(
string
),
list
)
class
MockOpener
:
class
MockOpener
:
addheaders
=
[]
addheaders
=
[]
...
...
Lib/urllib2.py
Dosyayı görüntüle @
e1b13d20
...
@@ -1072,46 +1072,43 @@ def parse_http_list(s):
...
@@ -1072,46 +1072,43 @@ def parse_http_list(s):
In particular, parse comma-separated lists where the elements of
In particular, parse comma-separated lists where the elements of
the list may include quoted-strings. A quoted-string could
the list may include quoted-strings. A quoted-string could
contain a comma.
contain a comma. A non-quoted string could have quotes in the
middle. Neither commas nor quotes count if they are escaped.
Only double-quotes count, not single-quotes.
"""
"""
# XXX this function could probably use more testing
res
=
[]
part
=
''
list
=
[]
end
=
len
(
s
)
escape
=
quote
=
False
i
=
0
for
cur
in
s
:
inquote
=
0
if
escape
:
start
=
0
part
+=
cur
while
i
<
end
:
escape
=
False
cur
=
s
[
i
:]
c
=
cur
.
find
(
','
)
q
=
cur
.
find
(
'"'
)
if
c
==
-
1
:
list
.
append
(
s
[
start
:])
break
if
q
==
-
1
:
if
inquote
:
raise
ValueError
,
"unbalanced quotes"
else
:
list
.
append
(
s
[
start
:
i
+
c
])
i
=
i
+
c
+
1
continue
continue
if
inquote
:
if
quote
:
if
q
<
c
:
if
cur
==
'
\\
'
:
list
.
append
(
s
[
start
:
i
+
c
])
escape
=
True
i
=
i
+
c
+
1
continue
start
=
i
elif
cur
==
'"'
:
inquote
=
0
quote
=
False
else
:
part
+=
cur
i
=
i
+
q
continue
else
:
if
c
<
q
:
if
cur
==
','
:
list
.
append
(
s
[
start
:
i
+
c
])
res
.
append
(
part
)
i
=
i
+
c
+
1
part
=
''
start
=
i
continue
else
:
inquote
=
1
if
cur
==
'"'
:
i
=
i
+
q
+
1
quote
=
True
return
map
(
lambda
x
:
x
.
strip
(),
list
)
part
+=
cur
# append last part
if
part
:
res
.
append
(
part
)
return
[
part
.
strip
()
for
part
in
res
]
class
FileHandler
(
BaseHandler
):
class
FileHandler
(
BaseHandler
):
# Use local file or FTP depending on form of URL
# Use local file or FTP depending on form of URL
...
...
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