Kaydet (Commit) 4b0f20de authored tarafından Raymond Hettinger's avatar Raymond Hettinger

Teach unquote() to handle unicode inputs

üst 239322b9
......@@ -415,6 +415,10 @@ class UnquotingTests(unittest.TestCase):
self.assertEqual(expect, result,
"using unquote_plus(): %s != %s" % (expect, result))
def test_unquote_with_unicode(self):
r = urllib.unquote(u'br%C3%BCckner_sapporo_20050930.doc')
self.assertEqual(r, u'br\xc3\xbcckner_sapporo_20050930.doc')
class urlencode_Tests(unittest.TestCase):
"""Tests for urlencode()"""
......
......@@ -1061,6 +1061,8 @@ def unquote(s):
res[i] = _hextochr[item[:2]] + item[2:]
except KeyError:
res[i] = '%' + item
except UnicodeDecodeError:
res[i] = unichr(int(item[:2], 16)) + item[2:]
return "".join(res)
def unquote_plus(s):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment