uri_reference.is_valid() accepts invalid hostnames and out-of-range ports

未关闭
#138 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

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

调研方向

首先在 Python REPL 中复现两个示例,并跟踪 uri_reference(...).is_valid() 如何验证主机名和端口。完成标准是拒绝带路径的裸主机名以及大于 65535 的端口,并通过测试覆盖报告的两个输入。

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

描述

The validator returns True for inputs that violate URI rules.

Examples:

In [15]:  uri_reference('google.com/path').is_valid()
Out[15]: True
In [27]:  uri_reference('http://example.com:99999/').is_valid()
Out[27]: True

Expected behavior:

The validator should reject missing schemes when a hostname is present
and should reject port values greater than 65535.

Actual behavior:

is_valid() returns True for both invalid inputs.

Steps to reproduce:

  1. Run the two example expressions in a Python REPL.
  2. Observe that both return True.

Environment:

Library version:
Python version: Python 3.10.14
OS: Windows

Fix? :

  • Add port range validation and treat bare hostnames with paths as invalid
  • unless explicitly allowed by the spec.
主要语言
Python
星标
189
派生
38
平均合并
13 小时 36 分钟
30 天内合并 PR
1

贡献指南

这个仓库没有索引到贡献指南

从这里开始

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

python-hyper/rfc3986 的其他 Issue

查看 python-hyper/rfc3986 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

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