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
f3e9b2a9
Kaydet (Commit)
f3e9b2a9
authored
Mar 18, 2010
tarafından
Senthil Kumaran
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fix for Issue8135 - urllib.unquote to support mixed percent escapes
üst
43fe03a2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
4 deletions
+31
-4
test_urllib.py
Lib/test/test_urllib.py
+26
-0
urllib.py
Lib/urllib.py
+2
-2
urlparse.py
Lib/urlparse.py
+3
-2
No files found.
Lib/test/test_urllib.py
Dosyayı görüntüle @
f3e9b2a9
...
@@ -439,6 +439,32 @@ class UnquotingTests(unittest.TestCase):
...
@@ -439,6 +439,32 @@ class UnquotingTests(unittest.TestCase):
"using unquote(): not all characters escaped: "
"using unquote(): not all characters escaped: "
"
%
s"
%
result
)
"
%
s"
%
result
)
def
test_unquoting_badpercent
(
self
):
# Test unquoting on bad percent-escapes
given
=
'
%
xab'
expect
=
given
result
=
urllib
.
unquote
(
given
)
self
.
assertEqual
(
expect
,
result
,
"using unquote():
%
r !=
%
r"
%
(
expect
,
result
))
given
=
'
%
x'
expect
=
given
result
=
urllib
.
unquote
(
given
)
self
.
assertEqual
(
expect
,
result
,
"using unquote():
%
r !=
%
r"
%
(
expect
,
result
))
given
=
'
%
'
expect
=
given
result
=
urllib
.
unquote
(
given
)
self
.
assertEqual
(
expect
,
result
,
"using unquote():
%
r !=
%
r"
%
(
expect
,
result
))
def
test_unquoting_mixed_case
(
self
):
# Test unquoting on mixed-case hex digits in the percent-escapes
given
=
'
%
Ab
%
eA'
expect
=
'
\xab\xea
'
result
=
urllib
.
unquote
(
given
)
self
.
assertEqual
(
expect
,
result
,
"using unquote():
%
r !=
%
r"
%
(
expect
,
result
))
def
test_unquoting_parts
(
self
):
def
test_unquoting_parts
(
self
):
# Make sure unquoting works when have non-quoted characters
# Make sure unquoting works when have non-quoted characters
# interspersed
# interspersed
...
...
Lib/urllib.py
Dosyayı görüntüle @
f3e9b2a9
...
@@ -1158,8 +1158,8 @@ def splitvalue(attr):
...
@@ -1158,8 +1158,8 @@ def splitvalue(attr):
if
match
:
return
match
.
group
(
1
,
2
)
if
match
:
return
match
.
group
(
1
,
2
)
return
attr
,
None
return
attr
,
None
_hex
tochr
=
dict
((
'
%02
x'
%
i
,
chr
(
i
))
for
i
in
range
(
256
))
_hex
dig
=
'0123456789ABCDEFabcdef'
_hextochr
.
update
((
'
%02
X'
%
i
,
chr
(
i
))
for
i
in
range
(
256
)
)
_hextochr
=
dict
((
a
+
b
,
chr
(
int
(
a
+
b
,
16
)))
for
a
in
_hexdig
for
b
in
_hexdig
)
def
unquote
(
s
):
def
unquote
(
s
):
"""unquote('abc
%20
def') -> 'abc def'."""
"""unquote('abc
%20
def') -> 'abc def'."""
...
...
Lib/urlparse.py
Dosyayı görüntüle @
f3e9b2a9
...
@@ -272,8 +272,9 @@ def urldefrag(url):
...
@@ -272,8 +272,9 @@ def urldefrag(url):
# Cannot use directly from urllib as it would create circular reference.
# Cannot use directly from urllib as it would create circular reference.
# urllib uses urlparse methods ( urljoin)
# urllib uses urlparse methods ( urljoin)
_hextochr
=
dict
((
'
%02
x'
%
i
,
chr
(
i
))
for
i
in
range
(
256
))
_hextochr
.
update
((
'
%02
X'
%
i
,
chr
(
i
))
for
i
in
range
(
256
))
_hexdig
=
'0123456789ABCDEFabcdef'
_hextochr
=
dict
((
a
+
b
,
chr
(
int
(
a
+
b
,
16
)))
for
a
in
_hexdig
for
b
in
_hexdig
)
def
unquote
(
s
):
def
unquote
(
s
):
"""unquote('abc
%20
def') -> 'abc def'."""
"""unquote('abc
%20
def') -> 'abc def'."""
...
...
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