New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
urlparse.urlparse misparses URLs with query but no path #45978
Comments
urlparse.urlparse will mis-parse URLs which have a "/" after a "?".
That's wrong. RFC3896 ("Uniform Resource Identifier (URI): Generic
So "urlparse" is an "older, erroneous implementation". Looking
OK, here's a fix to "urlparse", replacing _splitnetloc. I didn't use def _splitnetloc(url, start=0):
delim = len(url)# position of end of domain part of url, default is end
for c in '/?#': # look for delimiters; the order is NOT important
wdelim = url.find(c, start) # find first of this delim
if wdelim >= 0: # if found
delim = min(delim, wdelim)# use earliest delim position
return url[start:delim], url[delim:] # return (domain, rest) |
Would you mind submitting a proper patch for Python 2.5 and/or 2.6 |
I tried downloading the latest rev of urlparse.py (59480) and it flunked |
That's not the official test -- that code should probably be deleted. |
I checked in your change and made up a test. Committed revision 59758. Thanks! |
Backport to 2.5.2: |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: