summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_urllib.py15
-rw-r--r--Lib/urllib/parse.py2
2 files changed, 16 insertions, 1 deletions
diff --git a/Lib/test/test_urllib.py b/Lib/test/test_urllib.py
index da6bc2d..ba742af 100644
--- a/Lib/test/test_urllib.py
+++ b/Lib/test/test_urllib.py
@@ -510,6 +510,21 @@ class QuotingTests(unittest.TestCase):
self.assertEqual(expect, result,
"using quote(): %r != %r" % (expect, result))
+ def test_quote_plus_with_unicode(self):
+ # Encoding (latin-1) test for quote_plus
+ given = "\xa2\xd8 \xff"
+ expect = "%A2%D8+%FF"
+ result = urllib.parse.quote_plus(given, encoding="latin-1")
+ self.assertEqual(expect, result,
+ "using quote_plus(): %r != %r" % (expect, result))
+ # Errors test for quote_plus
+ given = "ab\u6f22\u5b57 cd"
+ expect = "ab%3F%3F+cd"
+ result = urllib.parse.quote_plus(given, encoding="latin-1",
+ errors="replace")
+ self.assertEqual(expect, result,
+ "using quote_plus(): %r != %r" % (expect, result))
+
class UnquotingTests(unittest.TestCase):
"""Tests for unquote() and unquote_plus()
diff --git a/Lib/urllib/parse.py b/Lib/urllib/parse.py
index 9033683..726e85f 100644
--- a/Lib/urllib/parse.py
+++ b/Lib/urllib/parse.py
@@ -488,7 +488,7 @@ def quote_plus(string, safe='', encoding=None, errors=None):
space = ' '
else:
space = b' '
- string = quote(string, safe + space)
+ string = quote(string, safe + space, encoding, errors)
return string.replace(' ', '+')
def quote_from_bytes(bs, safe='/'):