mirror of
https://github.com/python/cpython.git
synced 2025-12-09 18:48:05 +00:00
Teach unquote() to handle unicode inputs
This commit is contained in:
parent
239322b97e
commit
4b0f20def3
2 changed files with 6 additions and 0 deletions
|
|
@ -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):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue