mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
bpo-16285: Update urllib quoting to RFC 3986 (#173)
* bpo-16285: Update urllib quoting to RFC 3986 urllib.parse.quote is now based on RFC 3986, and hence includes `'~'` in the set of characters that is not escaped by default. Patch by Christian Theune and Ratnadeep Debnath.
This commit is contained in:
parent
140792bd51
commit
21024f0662
6 changed files with 27 additions and 7 deletions
|
@ -733,7 +733,7 @@ FF
|
|||
class QuotingTests(unittest.TestCase):
|
||||
r"""Tests for urllib.quote() and urllib.quote_plus()
|
||||
|
||||
According to RFC 2396 (Uniform Resource Identifiers), to escape a
|
||||
According to RFC 3986 (Uniform Resource Identifiers), to escape a
|
||||
character you write it as '%' + <2 character US-ASCII hex value>.
|
||||
The Python code of ``'%' + hex(ord(<character>))[2:]`` escapes a
|
||||
character properly. Case does not matter on the hex letters.
|
||||
|
@ -761,7 +761,7 @@ class QuotingTests(unittest.TestCase):
|
|||
do_not_quote = '' .join(["ABCDEFGHIJKLMNOPQRSTUVWXYZ",
|
||||
"abcdefghijklmnopqrstuvwxyz",
|
||||
"0123456789",
|
||||
"_.-"])
|
||||
"_.-~"])
|
||||
result = urllib.parse.quote(do_not_quote)
|
||||
self.assertEqual(do_not_quote, result,
|
||||
"using quote(): %r != %r" % (do_not_quote, result))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue