diff options
author | Jeremy Hylton <jeremy@alum.mit.edu> | 2000-08-31 15:48:10 (GMT) |
---|---|---|
committer | Jeremy Hylton <jeremy@alum.mit.edu> | 2000-08-31 15:48:10 (GMT) |
commit | 6102e29df28fa0707752875e23445ef1d84d5b10 (patch) | |
tree | 00cf5661ca3c395788a8ffad2c21b6bdef1a385a | |
parent | 7e861bd1b39e3a0f60e39e12483754558562cf07 (diff) | |
download | cpython-6102e29df28fa0707752875e23445ef1d84d5b10.zip cpython-6102e29df28fa0707752875e23445ef1d84d5b10.tar.gz cpython-6102e29df28fa0707752875e23445ef1d84d5b10.tar.bz2 |
fixes bug #111951
applies patch #101369 by Moshe Zadke
use explicit list of always safe characters instead of string.letters
add test case
-rw-r--r-- | Lib/test/output/test_urllib | 1 | ||||
-rw-r--r-- | Lib/test/test_urllib.py | 14 | ||||
-rw-r--r-- | Lib/urllib.py | 5 |
3 files changed, 18 insertions, 2 deletions
diff --git a/Lib/test/output/test_urllib b/Lib/test/output/test_urllib new file mode 100644 index 0000000..52a1c68 --- /dev/null +++ b/Lib/test/output/test_urllib @@ -0,0 +1 @@ +test_urllib diff --git a/Lib/test/test_urllib.py b/Lib/test/test_urllib.py new file mode 100644 index 0000000..245efb3 --- /dev/null +++ b/Lib/test/test_urllib.py @@ -0,0 +1,14 @@ +# Minimal test of the quote function +import urllib + +chars = 'abcdefghijklmnopqrstuvwxyz'\ + '\337\340\341\342\343\344\345\346\347\350\351\352\353\354\355\356' \ + '\357\360\361\362\363\364\365\366\370\371\372\373\374\375\376\377' \ + 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' \ + '\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317' \ + '\320\321\322\323\324\325\326\330\331\332\333\334\335\336' + +expected = 'abcdefghijklmnopqrstuvwxyz%df%e0%e1%e2%e3%e4%e5%e6%e7%e8%e9%ea%eb%ec%ed%ee%ef%f0%f1%f2%f3%f4%f5%f6%f8%f9%fa%fb%fc%fd%fe%ffABCDEFGHIJKLMNOPQRSTUVWXYZ%c0%c1%c2%c3%c4%c5%c6%c7%c8%c9%ca%cb%cc%cd%ce%cf%d0%d1%d2%d3%d4%d5%d6%d8%d9%da%db%dc%dd%de' + +test = urllib.quote(chars) +assert test == expected, "urllib.quote problem" diff --git a/Lib/urllib.py b/Lib/urllib.py index 2c6d878..4492e99 100644 --- a/Lib/urllib.py +++ b/Lib/urllib.py @@ -1011,7 +1011,9 @@ def unquote_plus(s): s = string.join(string.split(s, '+'), ' ') return unquote(s) -always_safe = string.letters + string.digits + '_,.-' +always_safe = ('ABCDEFGHIJKLMNOPQRSTUVWXYZ' + 'abcdefghijklmnopqrstuvwxyz' + '0123456789' '_,.-') def quote(s, safe = '/'): """quote('abc def') -> 'abc%20def'.""" # XXX Can speed this up an order of magnitude @@ -1043,7 +1045,6 @@ def urlencode(dict): l.append(k + '=' + v) return string.join(l, '&') - # Proxy handling def getproxies_environment(): """Return a dictionary of scheme -> proxy server URL mappings. |