Skip to content

fix(plist): decode OpenStep quoted string unicode and octal escape sequences - #8794

Merged
morluto merged 2 commits into
morluto:mainfrom
highmachs:fix/openstep-quoted-escapes
Nov 3, 2026
Merged

morluto merged 2 commits into
morluto:mainfrom
highmachs:fix/openstep-quoted-escapes

Conversation

@highmachs

Copy link
Copy Markdown
Contributor

Summary

Fixes #8661.

Supported OpenStep/old-style property lists (.plist) quoted strings can contain Unicode escape sequences (\Uxxxx where xxxx is up to 4 hex digits) and octal escape sequences (\ooo where ooo is 1 to 3 octal digits in NeXTSTEP encoding), as well as standard escapes \a, \b, \f, \n, \r, \t, \v, \", and \\.

Previously, decodeOpenStepPropertyList delegated quoted scalar tokens directly to the pinned plist parser, 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 in AppBundleExecutable.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 decodeOpenStepPropertyList matching Apple CoreFoundation's CFOldStylePList specification, correctly mapping \Uxxxx Unicode 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:

{ CFBundleExecutable = "M\U0061in"; }
{ CFBundleExecutable = "M\141in"; }
{ "CFBundle\U0045xecutable" = "Main"; }

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"
  • Consequently, list-architectures and app bundle resolution reported that the bundle executable was missing.

Expected behavior:

  • Correctly decode \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).
  • Apply escape decoding across both dictionary keys and values.
  • Preserve pinned parser syntax errors for unterminated strings and unterminated string escapes.

Change and scope

  • In src/domain/propertyListOpenStep.ts:
    • Added NEXT_STEP_LATIN_TABLE mapping 8-bit NeXTSTEP encoding (0x80 - 0xFF) to Unicode according to Apple CoreFoundation CFBuiltinConverters.c / CFOldStylePList.c.
    • Added decodeOpenStepQuotedString to decode Unicode \Uxxxx, octal \ooo, and control escapes while preserving pinned syntax validation.
    • Used decodeOpenStepQuotedString when parsing quoted tokens in decodeOpenStepPropertyList.
  • In src/domain/propertyListOpenStep.test.ts:
    • Added tests for Unicode escapes (\U0061, \U0045, \U00e9), octal escapes (\141, \335), control escapes (\a\b\f\v), and compound escapes.
  • In src/domain/propertyListKeys.test.ts:
    • Updated duplicate assignment test to reflect that octal-spelled "\\137_proto__" correctly resolves to "__proto__" and wins last-assignment semantics.
  • In tests/boundary/filesystem/binaryTarget.test.ts:
    • Added boundary test verifying resolveAppBundleExecutable resolves macOS app bundles whose Info.plist uses quoted Unicode and octal escapes in CFBundleExecutable and keys.

Contract and boundary impact

  • Semantic owner and earliest changed stage: Property list domain parser (propertyListOpenStep.ts).
  • Contribution scope fit: Fixes bug [Bug] OpenStep quoted escapes make existing app executables appear missing #8661.
  • CLI and MCP/tool-catalog contract: Backwards-compatible; improves accuracy of plist decoding and bundle executable resolution.
  • Evidence, artifact, provenance, or reconstruction contract: No changes to external evidence schemas.

Expected effects:

  • Read existing files or captured data.
  • Launch or attach to a process.
  • Inject instrumentation or run scripts/code.
  • Change process memory, registers, files, or configuration.
  • Contact network services.
  • Recover protected code or work around protections.
  • Documentation or usability only; no target interaction.
  • Not sure yet; investigation or maintainer guidance needed.

Evidence and regression coverage

  • Tests added or updated:
    • 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:

  • 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

  • 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

  • Breaking changes or migration steps: None.
  • Package or release metadata impact: None.

Author readiness

Human owner: @highmachs

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Before merge

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

Copilot AI balanced review requested due to automatic review settings November 3, 2026 13:48
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-03T14:11:01.164586Z aec6f01 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@greptile-apps

greptile-apps Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge, with the previous boundary-test finding addressed and no new blocking issue found.

Summary

The PR decodes Unicode, NeXTSTEP octal, and control escapes in OpenStep quoted keys and values.

  • OpenStep plists decode escaped names in quoted keys and values.

Reviews (2) · Last reviewed commit: "fix(plist): handle unpaired surrogate es..." · Reviewed by Greptile

Comment thread src/domain/propertyListOpenStep.test.ts Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread src/domain/propertyListOpenStep.ts Outdated
Comment on lines +129 to +133
const codePoint = NEXT_STEP_LATIN_TABLE[num - 0x80];
result +=
codePoint !== undefined && codePoint !== 0xfffd
? String.fromCharCode(codePoint)
: "";

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Comment thread src/domain/propertyListOpenStep.ts Outdated
break;
}
}
result += String.fromCharCode(num);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

@morluto
morluto merged commit 276d99e into morluto:main Nov 3, 2026
47 checks passed
@morluto morluto mentioned this pull request Nov 4, 2026
3 of 11 tasks
@morluto morluto added area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior bug Something isn't working labels Nov 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] OpenStep quoted escapes make existing app executables appear missing

3 participants