json_pretty inserts formatting inside strings, corrupting values and producing invalid JSON
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 78/100
Research direction
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.
Written by the indexing model from the issue text.
Description
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.
- Dominant language
- C
- Stars
- 3
- Forks
- 7
- Avg merge
- 3h 58m
- Merged PRs (30d)
- 105
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- Ships a Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from InauguralSystems/EigenScript
-
area:lint-tooling bug
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
InauguralSystems/EigenScript#1340 ·
Maintainers usually reply within 1 day
-
area:stdlib found-by:code-review kind:silent-wrong
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
InauguralSystems/EigenScript#1338 ·
Maintainers usually reply within 1 day
-
area:lint-tooling found-by:critic kind:docs-drift
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
InauguralSystems/EigenScript#1335 ·
Maintainers usually reply within 1 day
-
area:ci found-by:critic kind:gate-defect
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
InauguralSystems/EigenScript#1311 ·
Maintainers usually reply within 1 day
-
enrolment: decide test_gc_runner_controls.py (exempt vs enrol) and whether floors need a ratchetOpenarea:gates found-by:critic kind:decision
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
InauguralSystems/EigenScript#1280 · 1 comment ·
Maintainers usually reply within 1 day
All issues in InauguralSystems/EigenScript
Similar issues
-
Difficulty 1/5 1-3 hours Newbie friendliness 88/100
ClickHouse/pg_clickhouse#383 · 1 comment ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
johnsonjh/emu2-cpm86#68 · 1 comment ·
Maintainers usually reply within 1 day
-
Zenmap CrashOpenZenmap
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
BasedHardware/omi#19306 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
fastfetch-cli/fastfetch#2619 ·
Maintainers usually reply within 1 day