Repository navigation
fix(plist): decode hexadecimal XML integers as Apple's parser does - #3475
apitoagents wants to merge 2 commits into
Conversation
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
[Medium impact] The PR appears safe to merge; no new actionable issue was found. SummaryXML plist hexadecimal integers now decode to their numeric value, and large values can use the existing exact-decimal representation.
Reviews (4) · Last reviewed commit: "refactor(plist): convert only hexadecima..." · Reviewed by Greptile |
56ce031 to
62120d2
Compare
|
TL;DR: Fifteen new tests fail on main and all pass with this PR. A hexadecimal XML integer such as 0x2A now reads as 42, not 0. The PR needs a rebase, because a strict git apply fails on current main. Thanks, apitoagents, for the fix. I ran two test files on main 62bf098 (#4169). They are
The 15 failures are all new hexadecimal cases. They include 0x2A, 0X2a, +0x2A, -0x2A, a CDATA form, and two large values that need exact integers. Both the filesystem and the built CLI cases fail on main. Needs a rebaseOn main 62bf098, Not run
Commands# main 62bf09809 extracted to a work tree, then npm ci, npm run build, npm run test:prepare
git apply --check 3475.diff # exit 1 on propertyListKeys.ts
# merged tree: 3-way merge of propertyListKeys.ts, other five files taken from the PR
patch -p1 -d <tree> < merged.tests.diff
npm run test:focused -- src/domain/propertyListKeys.test.ts tests/boundary/filesystem/keyedArchiveScalarIdentity.test.ts # exit 1
patch -p1 -d <tree> < merged.src.diff
npm run test:focused -- src/domain/propertyListKeys.test.ts tests/boundary/filesystem/keyedArchiveScalarIdentity.test.ts # exit 0Test setup🤖 Generated with Claude Code (Sonnet 5.5, verified by Opus 5.5) 🦊 |
|
Thanks for running it. Rebased onto current main ( Validation on the rebased head as pushed, Node 24.15.0 (macOS):
Apple's parser: |
62120d2 to
561bcff
Compare
Interpret the validated, depth-bounded DOM directly. Collect source number facts during the same traversal and share them with keyed archives, Interface Builder and native plist projections. Remove the second XML parse, key aliases, source-location rewriting and both duplicate XML numeric scanners. Preserve character references, container/null behavior, safe own-property construction and prototype omission accounting. Decode signed hexadecimal integers and combine real text/CDATA. Retain exact integer identity when a finite integer exceeds even Number's finite range, using the shared scalar projector. Keep unsupported mixed integer syntax conservative and report incomplete metadata. Adapt @apitoagents's hexadecimal regression and literal-parsing proposal from PR #3475. Native plutil controls establish the supported hex/real cases and confirm that the synthetic 401-digit overflow case exceeds native bounds; retaining accepted input does not claim native-format support. Validation: 274 focused checks in 30 files pass, one skipped; build, check:fast and docs:check pass. Built CLI/actual stdio MCP, native plist and Interface Builder controls cover kinds, references, exact digits and digests. Eight baseline checks fail; native binary conversion independently verifies updated CDATA real expectations. 48 tiny completed CLI cost comparisons preserve ordinary XML/binary and all three native replies byte for byte. Two read-only reviews clear. No statistical speed claim, heavy profiler, investigated-target execution or real deep-provider verification. Fixes #3373 Fixes #4042 Fixes #4789
|
Superseded by 7aa4b98 (fix(plist): own XML values and numeric facts in one decoder), which decodes signed hexadecimal |
Summary
Fixes #3373.
inspect-keyed-archive/inspect_keyed_archivereported the valid XML plist integer<integer>0x2A</integer>as0. Apple's property-list parser (andplutil -p) reads the same bytes as42, and both the decimal spelling and a binary conversion of the same archive already returned42. Every XML plist consumer that goes throughparseXmlPropertyList(keyed archives, Info.plist resolution, Interface Builder documents, native plist inspection) now decodes hexadecimal integers to the value Apple's parser reports.Problem and expected behavior
The pinned
plistdecoder reads<integer>text withparseInt(text, 10), so a0x-prefixed literal decodes to0. The supplemental XML number collector also only recognised decimal digits, so a hexadecimal literal was recorded as "incomplete metadata" instead of being classified. Expected: the same value as the decimal spelling (42), with the exact-integer association still available for literals beyond 2^53.Change and scope
src/domain/apple/plistNumbers.ts: one owner for<integer>literal text,parsePlistIntegerLiteral, which reads an optional sign followed by decimal digits or a0x/0Xhexadecimal literal into an exactbigintand reports the radix.src/domain/propertyListKeys.ts: the existing__proto__key substitution is generalised intosubstituteDecoderDivergences. It locates first children the pinned decoder reads (rejected keys and hexadecimal integers) with the decoder's own XML parser, orders them by source position, and prefixes each with a CDATA section holding the text the decoder must read. The original source text is untouched, so character references and line endings keep their meaning exactly as before.src/artifacts/apple/PlistNumberLiterals.ts: the number collector uses the shared literal parser, so hexadecimal literals participate in exact-integer association instead of marking metadata incomplete.docs/native-investigation.md: one sentence in "Keyed archive integer precision".Intentionally not included: whitespace handling is unchanged (the decoder already tolerates surrounding whitespace for decimal text; Apple rejects it). Mixed content such as
<integer>0x2A<string>1</string></integer>keeps the decoder's first-child semantics (reads0x2A), matching how<key>first children are already treated; the collector still marks it incomplete.Scope decision: not applicable (ordinary fix within existing read-only boundaries).
Contract and boundary impact
parseXmlPropertyList(domain), XML plist decode.<integer>elements changes (from0to the Apple-parsed value).{ "$plist_type": "integer", "decimal": "<exact digits>" }representation.Expected effects:
Evidence and regression coverage
Tests added or updated:
src/domain/propertyListKeys.test.ts: hexadecimal spellings (0x2A,0X2a,+0x2A,-0x2A, entity-encoded, CDATA, trailing comment, surrounding whitespace, 2^53+1,0xFFFFFFFFFFFFFFFF) interleaved with__proto__keys before and after, to cover substitution ordering; hexadecimal text outside integers and non-literal integers (0x,0x1G) stay as decoded; first-child semantics for mixed content.tests/boundary/filesystem/keyedArchiveScalarIdentity.test.ts: newhexadecimal-integer(0x2A→42, no precision/incomplete-metadata limitation) andunsafe-hexadecimal-integer(0x20000000000001→ exact9007199254740993) cases, through bothinspectBundleKeyedArchiveand the built CLI.Base reproduction (executed): the issue's
sample.plistagainst the compiled runtime frommain(cbc0e97c2) returnednormalized_result.objects[1].value: 0. After this change the same command returnsvalue: 42,/usr/bin/plutil -preports42, and the decimal control (sed 's/0x2A/42/') returns42. Both runs exit 0.User-visible CLI/MCP output:
{"id":1,"kind":"scalar","class_id":null,"class_name":null,"status":"observed","value":42}.Remaining proof gaps:
plutilcomparison ran on macOS only. Occurrence of hexadecimal integers in real application archives was not measured (the issue reports the same).Observed, derived, and inferred claims remain distinguishable.
Artifact identity, source provenance, and failed attempts remain preserved.
Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.
Validation performed
npm run test:local -- src/domain/propertyListKeys.test.ts— 49 passednpm run test:focused -- tests/boundary/filesystem/keyedArchiveScalarIdentity.test.ts tests/boundary/filesystem/keyedArchiveIntegerAmbiguity.test.ts tests/boundary/providers/native/keyedArchiveEncoding.test.ts tests/boundary/cli/nativePlistCli.test.ts tests/boundary/cli/nativePlistPrototypeKeyCli.test.ts— 5 files, 33 passednpm run test:local -- src/artifacts/apple/KeyedArchiveReader.test.ts src/native/parsers/plist.test.ts src/domain/propertyListXmlText.test.ts— 32 passednpm run check:fast— typecheck and lint successfulnpm run verify:module-boundaries— 1878 source files checked, no violationsnode scripts/check-doc-facts.mjs— no output (pass)node scripts/rea.mjs inspect-keyed-archive sample.plist --json—value: 42after the change (0on the base revision)Compatibility, safety, and release
0; they now decode to their value.plutilcross-check on macOS 13 (Darwin 22.3.0).Author readiness
Human owner: @apitoagents
Before merge
type(scope): outcome.