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 摘要。