Skip to content

fix: a __proto__ key in a YAML sequence item is an entry, not the item's prototype - #384

Merged
TheAmericanMaker merged 1 commit into
mainfrom
fix/yaml-sequence-proto
Sep 16, 2026
Merged

TheAmericanMaker merged 1 commit into
mainfrom
fix/yaml-sequence-proto

Conversation

@TheAmericanMaker

Copy link
Copy Markdown
Member

Summary

Closes #365. Verified on main: core/yaml.ts parseSequence assigns item[key] = … (the item's first key, twice) and item[nestedKey] = nestedValue (the nested-mapping merge) with plain assignment while parseMapping uses Object.defineProperty for exactly this key; the new test fails on main — __proto__ is not an own key of the item and the item inherits polluted.

  • The three assignments go through one assignItem that uses defineProperty with the same descriptor the mapping parser uses.

Test plan

  • tests/yaml.test.mjs: __proto__ as the item's first key and as a nested key are own entries; nothing is inherited; the prototype is Object.prototype.
  • npm run build + npm test — 932 pass.

🤖 Generated with Claude Code

…m's prototype

The mapping parser guards __proto__ through defineProperty; the
sequence-item path plain-assigned the first key and the nested-mapping
merge, so a "- __proto__:" block set the item's prototype and vanished from
its own keys. Both sites now use the same guard.

Closes #365

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@TheAmericanMaker
TheAmericanMaker merged commit ac0d0ba into main Sep 16, 2026
5 checks passed
@TheAmericanMaker
TheAmericanMaker deleted the fix/yaml-sequence-proto branch September 16, 2026 02:02
@TheAmericanMaker TheAmericanMaker mentioned this pull request Sep 16, 2026
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.

yaml.ts sequence items bypass the __proto__ guard the mapping path applies

1 participant