GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — Parsing functions in urllib.parse remove the delimiters of empty URI components in violation of RFC 3986 · Issue #99962 · python/cpython Closed as duplicate Closed as duplicate Copy link Labels stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error DescriptionIssueHere is the generic syntax of a URI, consisting of five components:
So we need two distinct representations for undefined components and empty components. Currently the functions >>> from urllib.parse import urldefrag, urlparse, urlsplit >>> >>> urldefrag('scheme://authority/path?query#fragment').geturl() 'scheme://authority/path?query#fragment' >>> urldefrag('scheme:///path?query#fragment').geturl() # empty authority 'scheme:/path?query#fragment' >>> urldefrag('scheme://authority/path?#fragment').geturl() # empty query 'scheme://authority/path#fragment' >>> urldefrag('scheme://authority/path?query#').geturl() # empty fragment 'scheme://authority/path?query' >>> >>> urlparse('scheme://authority/path?query#fragment').geturl() 'scheme://authority/path?query#fragment' >>> urlparse('scheme:///path?query#fragment').geturl() # empty authority 'scheme:/path?query#fragment' >>> urlparse('scheme://authority/path?#fragment').geturl() # empty query 'scheme://authority/path#fragment' >>> urlparse('scheme://authority/path?query#').geturl() # empty fragment 'scheme://authority/path?query' >>> >>> urlsplit('scheme://authority/path?query#fragment').geturl() 'scheme://authority/path?query#fragment' >>> urlsplit('scheme:///path?query#fragment').geturl() # empty authority 'scheme:/path?query#fragment' >>> urlsplit('scheme://authority/path?#fragment').geturl() # empty query 'scheme://authority/path#fragment' >>> urlsplit('scheme://authority/path?query#').geturl() # empty fragment 'scheme://authority/path?query'
>>> from urllib.parse import urlparse >>> >>> urlparse('http://authority/path;parameter?query#fragment').geturl() 'http://authority/path;parameter?query#fragment' >>> urlparse('http://authority/path;?query#fragment').geturl() # empty parameter 'http://authority/path?query#fragment' All those URI pairs (before and after parsing) with empty components are not equivalent so the current parsing violates the URI specification by removing the associated delimiters (cf. RFC 3986, § 6.2.3):
SolutionIn PR #15642, I proposed to use The benefit of the In PR #15642 (comment), @nicktimko suggested an alternative representation for undefined components:
As he noted, The benefit of an In PR #15642 (comment), @nicktimko suggested another representation for undefined components:
For representing undefined components, we could use a member of an The benefit of that Activity
MetadataMetadataAssigneesLabelsstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error ProjectsMilestoneRelationshipsDevelopmentIssue actions |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |