Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(33464)

Side by Side Diff: Lib/urllib/parse.py

Issue 16285: Update urllib quoting to RFC 3986
Patch Set: Created 5 years, 2 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Lib/test/test_urllib.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 """Parse (absolute and relative) URLs. 1 """Parse (absolute and relative) URLs.
2 2
3 urlparse module is based upon the following RFC specifications. 3 urlparse module is based upon the following RFC specifications.
4 4
5 RFC 3986 (STD66): "Uniform Resource Identifiers" by T. Berners-Lee, R. Fielding 5 RFC 3986 (STD66): "Uniform Resource Identifiers" by T. Berners-Lee, R. Fielding
6 and L. Masinter, January 2005. 6 and L. Masinter, January 2005.
7 7
8 RFC 2732 : "Format for Literal IPv6 Addresses in URL's by R.Hinden, B.Carpenter 8 RFC 2732 : "Format for Literal IPv6 Addresses in URL's by R.Hinden, B.Carpenter
9 and L.Masinter, December 1999. 9 and L.Masinter, December 1999.
10 10
(...skipping 605 matching lines...) Expand 10 before | Expand all | Expand 10 after
616 unquoting HTML form values. 616 unquoting HTML form values.
617 617
618 unquote_plus('%7e/abc+def') -> '~/abc def' 618 unquote_plus('%7e/abc+def') -> '~/abc def'
619 """ 619 """
620 string = string.replace('+', ' ') 620 string = string.replace('+', ' ')
621 return unquote(string, encoding, errors) 621 return unquote(string, encoding, errors)
622 622
623 _ALWAYS_SAFE = frozenset(b'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 623 _ALWAYS_SAFE = frozenset(b'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
624 b'abcdefghijklmnopqrstuvwxyz' 624 b'abcdefghijklmnopqrstuvwxyz'
625 b'0123456789' 625 b'0123456789'
626 b'_.-') 626 b'_.-~')
627 _ALWAYS_SAFE_BYTES = bytes(_ALWAYS_SAFE) 627 _ALWAYS_SAFE_BYTES = bytes(_ALWAYS_SAFE)
628 _safe_quoters = {} 628 _safe_quoters = {}
629 629
630 class Quoter(collections.defaultdict): 630 class Quoter(collections.defaultdict):
631 """A mapping from bytes (in range(0,256)) to strings. 631 """A mapping from bytes (in range(0,256)) to strings.
632 632
633 String values are percent-encoded byte values, unless the key < 128, and 633 String values are percent-encoded byte values, unless the key < 128, and
634 in the "safe" set (either the specified safe set, or default set). 634 in the "safe" set (either the specified safe set, or default set).
635 """ 635 """
636 # Keeps a cache internally, using defaultdict, for efficiency (lookups 636 # Keeps a cache internally, using defaultdict, for efficiency (lookups
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
964 _valueprog = None 964 _valueprog = None
965 def splitvalue(attr): 965 def splitvalue(attr):
966 """splitvalue('attr=value') --> 'attr', 'value'.""" 966 """splitvalue('attr=value') --> 'attr', 'value'."""
967 global _valueprog 967 global _valueprog
968 if _valueprog is None: 968 if _valueprog is None:
969 _valueprog = re.compile('^([^=]*)=(.*)$') 969 _valueprog = re.compile('^([^=]*)=(.*)$')
970 970
971 match = _valueprog.match(attr) 971 match = _valueprog.match(attr)
972 if match: return match.group(1, 2) 972 if match: return match.group(1, 2)
973 return attr, None 973 return attr, None
OLDNEW
« no previous file with comments | « Lib/test/test_urllib.py ('k') | no next file » | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+