vercel-labs / vercel-labs/json-render
Array path helpers accept malformed RFC 6902 indexes
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 16.8k
- Forks
- 901
- Avg merge
- 3h 14m
- Merged PRs (30d)
- 4
Description
Reproduction
const data = { items: ["a", "b", "c"] };
getByPath(data, "/items/1foo"); // "b"
setByPath(data, "/items/01", "x"); // writes index 1
addByPath(data, "/items/1.5", "x"); // inserts at index 1
removeByPath(data, "/items/-1"); // may address a non-index array property
The state-store path setter has the same parsing behavior.
Expected behavior
When the current container is an array, path tokens should follow the RFC 6902 array-index grammar: 0 or a non-zero digit followed by digits. Partial numeric strings, leading zeros, decimals, negative values, and integers that cannot be represented safely should be rejected rather than coerced with parseInt.
Object member names should remain unrestricted, including numeric-looking keys.
Proposed fix
Use strict, safe-integer parsing only while traversing arrays, preserve object-key behavior, and add regression coverage for mutable path helpers and state-store writes.
I have a focused patch ready with regression tests.
Contributor guide
No contributing guide indexed for this repository
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.
Research direction
Locate the getByPath, setByPath, addByPath, and removeByPath helpers, then find the state-store path setter and its existing tests. Add regression coverage showing malformed array indexes are rejected while numeric-looking object keys remain valid, and confirm mutable path helpers and state-store writes follow the expected RFC 6902 behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 72/100