Draft-3 time format accepts unpadded components and non-ASCII digits

未关闭 适合新手
#1,610 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 6 天内回复

还没有人认领这个 Issue。

评估

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

调研方向

首先找到 Draft 3 的 time 格式检查器及其测试;issue 未注明它们的文件路径。检查解析如何处理未补零的组成部分和 Unicode 数字,然后将其行为与更严格的日期和 UUID 检查器进行比较。完成标准是:格式错误的示例会被拒绝,补零后的时间会被接受,并且对非字符串值的行为保持不变。

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

描述

With format checking explicitly enabled, Draft3Validator accepts malformed time strings:

from jsonschema import Draft3Validator
v = Draft3Validator({"format": "time"}, format_checker=Draft3Validator.FORMAT_CHECKER)
v.is_valid("1:2:3")        # True
v.is_valid("01:0\u0662:03")  # True

The draft-3 specification describes time as hh:mm:ss: https://datatracker.ietf.org/doc/html/draft-zyp-json-schema-03#section-5.23 . Python strptime accepts missing padding and Unicode decimal digits, so parsing successfully does not establish the required textual format. The date and UUID format checkers already enforce stricter textual representations.

Expected: reject these malformed strings while accepting padded times and preserving non-string behavior. Five malformed-value subtests fail on unchanged main. A focused fix compares the parsed time's canonical HH:MM:SS representation with the original input.

Impact: invalid time data passes explicitly requested format validation in applications using draft-3 schemas. I assess this as medium severity, not a maintainer-assigned severity label. Codex assisted with investigation, implementation and tests.

主要语言
Python
星标
5k
派生
741
平均合并
4 天 17 小时
30 天内合并 PR
6

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

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

python-jsonschema/jsonschema 的其他 Issue

查看 python-jsonschema/jsonschema 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

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