Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

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

Đã đóng
#1,249 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
78/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
c
Lĩnh vực
tooling

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
C
Star
3
Fork
7
Merge trung bình
4 giờ 5 phút
Pull request đã merge (30 ngày)
116

Chuẩn bị môi trường

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của InauguralSystems/EigenScript

Tất cả issue của InauguralSystems/EigenScript

Issue tương tự

Thêm issue về C

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.