python / python/cpython

URL Parse Split incorreclty interpret proxy pw, which include '?'

未关闭
#101,186 3 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

stdlib
主要语言
Python
星标
77.2k
派生
36k
平均合并
1 天 9 小时
30 天内合并 PR
558

描述

Hi,

I have exported the env var for http proxy, where the Username and password is included in the URL.
The password of the user includes an '?', which is the reason, why the URL string is not correctly processed.

The URL
http_proxy='http://<username>:<pass_with_?>@<server>:<port>'

When the method splits:
https://github.com/python/cpython/blob/53d9cd95cd91f1a291a3923acb95e0e86942291a/Lib/urllib/parse.py#L477

It splits at the ? of the password.

Therefore resulting into

 File "/usr/lib/python3/dist-packages/httplib2/__init__.py", line 950, in proxy_info_from_url
    port = int(port)
ValueError: invalid literal for int() with base 10: 'p'

if the URL would be:

http://user:p?assword@server:port

Regards
Nam

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

从 Lib/urllib/parse.py 中 issue 所链接的 URL 分割代码开始,复现对 http://user:p?assword@server:port 的解析。确认代理凭据中问号的预期处理方式,然后验证该示例不再将密码的一部分视为单独的 URL 组件。

由索引模型根据 Issue 内容生成。

评估

技术栈
python
领域
networking
Issue 类型
缺陷
难度
2/5
预计耗时
1-3 小时
活跃度
停滞
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。