A JSON body that starts with a brace can be parsed from the middle
评估
调研方向
首先在 HTTPie 源代码中定位 load_prefixed_json 函数,并重现 issue 中的示例。检查前缀搜索的行为及其现有测试(如果有)。当以额外花括号开头的 JSON 样字符串被拒绝,而不是从中间开始解析,同时像 while(1); 这样的有效前缀能够保留时,即表示完成。
由索引模型根据 Issue 内容生成。
描述
Describe the bug
load_prefixed_json('{{"a": 1}') returns the prefix a and the object {"a": 1}. The string is not JSON, and a is not a prefix. while(1);{"a": 1} should still return the prefix while(1); and the object.
The prefix search uses re.findall and then cuts len(match) characters off the front, even when that match does not start at the front.
To Reproduce
from httpie.output.utils import load_prefixed_json
print(load_prefixed_json('{{"a": 1}'))
- 主要语言
- Python
- 星标
- 38.8k
- 派生
- 4k
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
httpie/cli 的其他 Issue
-
Header formatting reorders repeated fields with mixed capitalization可能已有人在做 @xu91102 于 18 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 72/100
-
JSON formatting ignores uppercase and mixed-case Content-Type values可能已有人在做 @xu91102 于 18 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 72/100
-
new
难度 2/5 1-3 小时 新手友好度 70/100
-
Bug: Windows guard in is_available() compares os.system (a function) to 'nt' — always False可能已有人在做 @yoshibase 于 92 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
-
Inconsistent argument parsing behavior across Python versions (< 3.13 vs 3.13+)可能已有人在做 @BetterAndBetterII 于 40 天前认领。 未关闭bug new
难度 4/5 3-5 天 新手友好度 48/100
相似的 Issue
-
md/asciidoc/csv: an explicit `encoding="utf-8"` keeps a leading BOM, the auto-detect path drops it未关闭
难度 2/5 1-3 小时 新手友好度 82/100
docling-project/docling#4846 ·
维护者通常 1 天内回复
-
area/sessions comp/dashboard comp/desktop comp/gateway comp/tui duplicate P2 sweeper:risk-session-state type/bug
难度 2/5 1-3 小时 新手友好度 78/100
NousResearch/hermes-agent#138914 · 1 条评论 ·
维护者通常 1 天内回复
-
bot-triaged module: activation checkpointing module: inductor oncall: pt2 triaged
难度 2/5 1-3 小时 新手友好度 62/100
维护者通常 1 天内回复
-
[oblt-aw][autodoc] Update PR Actions Detective E2E prerequisites and fix dashboard-format table typo未关闭documentation
难度 2/5 1-3 小时 新手友好度 75/100
elastic/oblt-aw#2382 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 74/100
维护者通常 1 天内回复