Repository navigation
fix(plist): decode OpenStep quoted string unicode and octal escape sequences - #8794
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
[Medium impact] The PR appears safe to merge, with the previous boundary-test finding addressed and no new blocking issue found. SummaryThe PR decodes Unicode, NeXTSTEP octal, and control escapes in OpenStep quoted keys and values.
Reviews (2) · Last reviewed commit: "fix(plist): handle unpaired surrogate es..." · Reviewed by Greptile |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a3b270d4d9
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| const codePoint = NEXT_STEP_LATIN_TABLE[num - 0x80]; | ||
| result += | ||
| codePoint !== undefined && codePoint !== 0xfffd | ||
| ? String.fromCharCode(codePoint) | ||
| : ""; |
There was a problem hiding this comment.
Preserve the full three-digit octal semantics
When a string contains \376/\377 or an accepted three-digit overflow such as \541, this lookup selects the empty fallback and silently removes the escape. Swift 6.2.4 Foundation's old-style parser instead appends NUL for the first cases and narrows the latter to one byte (a), so this produces different dictionary keys and CFBundleExecutable names. Preserve the converter's byte/failure behavior instead of treating a missing or sentinel table entry as omission.
AGENTS.md reference: AGENTS.md:L19-L19
Useful? React with 👍 / 👎.
| break; | ||
| } | ||
| } | ||
| result += String.fromCharCode(num); |
There was a problem hiding this comment.
Replace unpaired Unicode escape surrogates
When a \Uxxxx value is a lone surrogate, such as \Ud800, String.fromCharCode leaves an unpaired UTF-16 code unit in the parsed key or value. Swift 6.2.4 Foundation's old-style parser emits U+FFFD for that input while preserving a well-formed high/low escape pair, so the current result compares and serializes differently and can make escaped dictionary keys unfindable. Validate surrogate pairing while decoding and replace only unpaired units.
AGENTS.md reference: AGENTS.md:L27-L27
Useful? React with 👍 / 👎.
Summary
Fixes #8661.
Supported OpenStep/old-style property lists (.plist) quoted strings can contain Unicode escape sequences (
\Uxxxxwherexxxxis up to 4 hex digits) and octal escape sequences (\ooowhereooois 1 to 3 octal digits in NeXTSTEP encoding), as well as standard escapes\a,\b,\f,\n,\r,\t,\v,\", and\\.Previously,
decodeOpenStepPropertyListdelegated quoted scalar tokens directly to the pinnedplistparser, which dropped the backslash instead of decoding Unicode and octal escapes (e.g."M\U0061in"became"MU0061in"and"M\141in"became"M141in"). When resolving app bundle executables inAppBundleExecutable.ts, this caused bundle executable resolution and architecture listing to fail or search for nonexistent binaries.This change introduces compliant quoted escape sequence decoding in
decodeOpenStepPropertyListmatching Apple CoreFoundation'sCFOldStylePListspecification, correctly mapping\UxxxxUnicode escapes, NeXTSTEP Latin octal escapes, and standard escapes for both dictionary keys and values.Problem and expected behavior
In old-style/OpenStep plists (
Info.plist), bundle declarations such as:all decode to
CFBundleExecutable: "Main"in Apple Foundation (/usr/bin/plutil -convert json).Previously in REA:
"M\U0061in"was parsed as"MU0061in""M\141in"was parsed as"M141in""CFBundle\U0045xecutable"was parsed as"CFBundleU0045xecutable"list-architecturesand app bundle resolution reported that the bundle executable was missing.Expected behavior:
\Uxxxx(4-hex unicode characters),\ooo(1-3 octal characters mapped through the 128-byte NeXTSTEP Latin encoding table), and standard C escape characters (\a,\b,\f,\n,\r,\t,\v,\",\\,\newline).Change and scope
src/domain/propertyListOpenStep.ts:NEXT_STEP_LATIN_TABLEmapping 8-bit NeXTSTEP encoding (0x80 - 0xFF) to Unicode according to Apple CoreFoundationCFBuiltinConverters.c/CFOldStylePList.c.decodeOpenStepQuotedStringto decode Unicode\Uxxxx, octal\ooo, and control escapes while preserving pinned syntax validation.decodeOpenStepQuotedStringwhen parsing quoted tokens indecodeOpenStepPropertyList.src/domain/propertyListOpenStep.test.ts:\U0061,\U0045,\U00e9), octal escapes (\141,\335), control escapes (\a\b\f\v), and compound escapes.src/domain/propertyListKeys.test.ts:"\\137_proto__"correctly resolves to"__proto__"and wins last-assignment semantics.tests/boundary/filesystem/binaryTarget.test.ts:resolveAppBundleExecutableresolves macOS app bundles whoseInfo.plistuses quoted Unicode and octal escapes inCFBundleExecutableand keys.Contract and boundary impact
propertyListOpenStep.ts).Expected effects:
Evidence and regression coverage
src/domain/propertyListOpenStep.test.ts: 39 passed.src/domain/propertyListKeys.test.ts: 46 passed.tests/boundary/filesystem/binaryTarget.test.ts: verifies OpenStep app bundle executable resolution with escaped keys and values.For evidence-bearing changes:
Validation performed
npx vitest run src/domain/propertyListOpenStep.test.ts(39 passed).npx vitest run src/domain/propertyListKeys.test.ts src/domain/propertyListOpenStepComments.test.ts(53 passed).npx vitest run tests/boundary/filesystem/binaryTarget.test.ts -t "resolves an OpenStep bundle executable"(3 passed).npm run compile(0 errors).npm run check:fast(turbo typecheck & lint 100% green).npm run verify:module-boundaries(0 errors across 3557 source files).npm run verify:test-discovery(2987 test files discovered exactly once).Compatibility, safety, and release
Author readiness
Human owner: @highmachs
Before merge
type(scope): outcome.