python / python/cpython

is it necessary the urllib.parse._splitnetloc support # and ? in username or password within the netloc?

Aperta
#118,641 1 commento 1 reazione 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

type-feature
Lingua principale
Python
Stelle
77.2k
Fork
35.9k
Metriche di merge delle PR
Metriche PR in attesa

Descrizione

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

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia esaminando urllib.parse._splitnetloc e l’esempio di URL in stile MySQL nell’issue. Determina la gestione prevista di # e ? nei nomi utente o nelle password all’interno di netloc, quindi verifica che il comportamento scelto preservi i delimitatori URL rimanenti e non introduca regressioni nell’analisi.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
python
Ambito
backend
Tipo di issue
Funzionalità
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.