python / python/cpython

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

未關閉
#118,641 1 則留言 1 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

type-feature
主要語言
Python
星號
77.2k
分支
35.9k
PR 合併指標
PR 指標待擷取

描述

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

貢獻指南

開啟貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

研究方向

首先檢視 urllib.parse._splitnetloc 以及 issue 中的 MySQL-style URL 範例。判斷 netloc 中使用者名稱或密碼內的 # 和 ? 應如何處理,然後確認選定的行為能保留其餘的 URL 分隔符,且不會引入解析回歸問題。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
python
領域
backend
Issue 類型
功能
難度
4/5
預估耗時
3-5 天
活躍度
停滯
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。