summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_urllib.py
diff options
context:
space:
mode:
authorSenthil Kumaran <orsenthil@gmail.com>2010-03-18 12:14:15 (GMT)
committerSenthil Kumaran <orsenthil@gmail.com>2010-03-18 12:14:15 (GMT)
commitf3e9b2a996d9f18bf7060e0bff85c02bee47c490 (patch)
treef31606afa4463772a7591c526d90af64fe790e9c /Lib/test/test_urllib.py
parent43fe03a2062c8eb3b688a28cd9174a14a43eecf3 (diff)
downloadcpython-f3e9b2a996d9f18bf7060e0bff85c02bee47c490.zip
cpython-f3e9b2a996d9f18bf7060e0bff85c02bee47c490.tar.gz
cpython-f3e9b2a996d9f18bf7060e0bff85c02bee47c490.tar.bz2
Fix for Issue8135 - urllib.unquote to support mixed percent escapes
Diffstat (limited to 'Lib/test/test_urllib.py')
-rw-r--r--Lib/test/test_urllib.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/Lib/test/test_urllib.py b/Lib/test/test_urllib.py
index 1cf8e44..9bd8857 100644
--- a/Lib/test/test_urllib.py
+++ b/Lib/test/test_urllib.py
@@ -439,6 +439,32 @@ class UnquotingTests(unittest.TestCase):
"using unquote(): not all characters escaped: "
"%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):
# Make sure unquoting works when have non-quoted characters
# interspersed