python / python/cpython

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

オープン
#118,641 コメント 1 件 リアクション 1 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

type-feature
主要言語
Python
スター
77.2k
フォーク
36k
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. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

まず urllib.parse._splitnetloc と issue 内の MySQL-style URL の例を確認します。netloc 内のユーザー名またはパスワードに含まれる # と ? の意図された扱いを判断し、選択した動作によって残りの URL デリミタが維持され、パースのリグレッションが発生しないことを確認します。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
python
領域
backend
issue の種類
機能追加
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。