is it necessary the urllib.parse._splitnetloc support # and ? in username or password within the netloc?
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 77.2k
- Forks
- 35.9k
- PR merge metrics
- PR metrics pending
Description
Feature or enhancement
Proposal:
def _splitnetloc(url: str, start=0):
delim = len(url) # position of end of domain part of url, default is end
**slashlim, queslim, warnlim = [url.find(c, start) for c in '/?#']**
**if slashlim > queslim or slashlim > warnlim:** # support the character '#' or '?' in the username or password within the netloc.
**return url[start:slashlim], url[slashlim:]**
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)
the situation from linked the mysql url, e.g., mysql://test123:test#789@127.0.0.1:6313/urlTest?charset=utf8#section1.
when the password has '#' or '?' word in the netloc, it brings exception.
As result of the '/' index value is higher than the '#', I wanna whether it is necessary to level it up.
I suggest a proposal that is the code wrapped by **.
Besides, using the quote/quote_plus/unquote could figure it out. however, it need to parse the username, password, hostname, port before.
Or, we have others.
Sincerely
Has this already been discussed elsewhere?
No response given
Links to previous discussion of this feature:
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing urllib.parse._splitnetloc and the MySQL-style URL example in the issue. Determine the intended handling of # and ? in usernames or passwords within the netloc, then verify that the chosen behavior preserves the remaining URL delimiters and does not introduce parsing regressions.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100