Repository navigation
fix: keep "__proto__" dictionary keys as own properties - #58
Merged
Merged
Conversation
parseDictionary assigned entries with dict[key] = val. For the key "__proto__" (or any key object that coerces to it) that calls the Object.prototype setter, so the entry was dropped and a dictionary value became the prototype of the result. Define every entry with Object.defineProperty instead. Fixes #57
bardrop
force-pushed
the
fix-proto-dictionary-key
branch
from
November 14, 2026 08:29
0c31316 to
ea94b6b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #57
parseDictionaryfilled the result withdict[key] = val. For the key__proto__that runs theObject.prototype.__proto__setter, so:__proto__entry was missing from the parsed object, andr.isAdmin === truein the issue's repro).Now every entry is added with
Object.defineProperty(enumerable, writable, configurable, same as a normal assignment), so__proto__shows up as an own property like it does in Python'splistlib. I did it for every key, not justkey === "__proto__", because the parser doesn't require keys to be strings, and a non-string key such as an array["__proto__"]would still coerce to"__proto__"and hit the setter.Testing: new test in
test/parse.test.tsuses the binary plist from the issue (made withplistlib.dumps(..., fmt=plistlib.FMT_BINARY)). It fails onmasterand passes here.npm test(12 pass),npm run typecheckandnpm run smokepass.npm run lintshows the same 12 problems as onmaster, none in the changed lines.