Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

json_pretty inserts formatting inside strings, corrupting values and producing invalid JSON

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

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

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

调研方向

Start with lib/json.eigs:55–94 and run the supplied program through src/eigenscript to observe the corruption. Add regression coverage for punctuation, escaped quotes, backslashes, and nested arrays or objects, using an independent JSON validity check. Done means formatting occurs only outside strings and all string values remain exact; docs/STDLIB.md:488 describes the promised API.

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

描述

area:stdlib bug found-by:code-review kind:silent-wrong

json.json_pretty inserts indentation inside JSON strings. Valid JSON becomes invalid JSON, and the string value changes if the output is decoded by EigenScript's permissive string decoder.

Reproduce

Save this program and run it with src/eigenscript:

import json
original is "{\"s\":\"a,b\"}"
pretty is json.json_pretty of original
print of pretty
print of (json_encode of (json_decode of pretty))

Actual formatted text:

{
  "s":"a,
  b"
}

Expected: the value remains exactly a,b; formatting whitespace is inserted only outside JSON strings. Python's json.loads rejects the actual text with Invalid control character. EigenScript's decoder accepts the raw newline and re-encodes the changed value as {"s":"a,\n b"}.

Cause and coverage

lib/json.eigs:55–94 reacts to every brace, bracket and comma without tracking whether the current character is inside a JSON string or follows an escape. The public API promises indented JSON output.

No existing test calls json_pretty. Regression cases should preserve exact string values containing punctuation, escaped quotes and backslashes, while still indenting real arrays/objects. Merely checking that EigenScript's decoder accepts the output is insufficient: its permissive decoder accepts this corrupted result. Include an independent JSON validity check or verify that no unescaped control characters were inserted into string tokens.

Confirmed with a fresh default release build of b91768e23c5a874a64e76e4af9ab291e6aa49983, with inherited EIGS_* variables removed.

主要语言
C
星标
3
派生
7
平均合并
4 小时 5 分钟
30 天内合并 PR
116

环境准备

在 Codespaces 中打开

在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。

从这里开始

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

InauguralSystems/EigenScript 的其他 Issue

查看 InauguralSystems/EigenScript 的全部 Issue

相似的 Issue

更多 C Issue

把新 issue 发到你的邮箱

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