Skip to content

fix: parse embedded JSON without counting braces inside strings - #142

Open
00200200 wants to merge 1 commit into
anthropics:mainfrom
00200200:codex/security-json-string-braces
Open

00200200 wants to merge 1 commit into
anthropics:mainfrom
00200200:codex/security-json-string-braces

Conversation

@00200200

@00200200 00200200 commented Sep 14, 2026

Copy link
Copy Markdown

The fallback parser loses valid results when a JSON string contains an unmatched brace, or surrounding prose contains a stray closing brace. Track quotes and escape sequences while locating balanced objects, and preserve empty objects/arrays returned by fenced JSON. Existing extraction precedence remains unchanged.

Validation: python -m pytest claudecode/test_json_parser.py -q (============================== 21 passed in 0.66s ==============================). The regression tests fail on the unchanged main branch. Tests use local fixtures; no paid API calls.

Additional checks: /python -m pytest claudecode -q.

Prepared with Codex assistance; the final diff and regression behavior were checked locally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant