Repository navigation
fix(ghidra): read UTF-8 signed language definitions - #2772
Merged
Merged
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. |
Contributor
|
Buffer#toString kept a leading UTF-8 byte order mark as U+FEFF, so the strict XML parser rejected a valid .ldefs file as content outside the root element and aborted the whole language catalog read. XML 1.0 section 4.3.3 defines the mark as an encoding signature; decode with TextDecoder, which consumes it. Malformed XML is still rejected. Fixes morluto#2533 Co-Authored-By: Claude Opus 5.5 <[email protected]>
yasshmittal
force-pushed
the
fix/ghidra-ldefs-bom
branch
from
October 13, 2026 12:09
9092085 to
b9a1398
Compare
This was referenced Oct 13, 2026
Owner
|
Thanks for handling BOM-prefixed Ghidra language files, @yasshmittal. One valid |
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.
Summary
Fixes #2533.
A valid Ghidra
.ldefsfile that begins with a UTF-8 byte order mark aborted the entire language-catalog read. Profile resolution reads that catalog before admittingREA_GHIDRA_LANGUAGE_ID, so one signed file blocked every configured language override.Problem and expected behavior
readGhidraLanguageCatalogdecoded each file withBuffer#toString("utf8"), which keeps the mark as U+FEFF. The strict XML parser then rejected it as content outside the root element. XML 1.0 section 4.3.3 defines the mark as an encoding signature, not document content, so a signed and an unsigned copy of the same document should produce the same catalog.Change and scope
Each file is now decoded with
TextDecoder, which consumes a leading UTF-8 BOM as part of decoding. The fix sits at the byte-to-text boundary, soparseGhidraLanguageDefinitionskeeps its strict behavior. Invalid UTF-8 handling (replacement characters) is unchanged, and malformed XML is still rejected.Not included: honoring non-UTF-8 encoding declarations (for example UTF-16 documents), which were not supported before this change either.
Contribution scope: an ordinary fix within existing boundaries; no maintainer scope decision applies.
Contract and boundary impact
Semantic owner and earliest changed stage:
.ldefsbyte decoding insrc/ghidra/GhidraLanguageCatalog.ts.Contribution scope fit and linked maintainer decision: not applicable (bug fix).
CLI and MCP/tool-catalog contract: unchanged.
Provider, bridge, target-format, or platform compatibility: Ghidra installations with signed
.ldefsfiles now load their catalog.Evidence, artifact, provenance, or reconstruction contract: unchanged.
Target selection, authority, upstream behavior, and cleanup details: no Ghidra launch or project change; read-only file parsing.
Generated metadata, package, or installation impact: none.
Read existing files or captured data.
Evidence and regression coverage
Tests added or updated:
src/ghidra/GhidraLanguageOverride.test.tsbuilds an installation containing a BOM-signed definition beside an unsigned sibling module and requires both languages to load in order. The existing malformed-document cases still require rejection.Base reproduction or other evidence: on the base revision the signed file rejects the whole catalog with a parse error naming U+FEFF, as in the issue.
User-visible CLI/MCP output: a configured language defined in a signed file is admitted instead of failing as a provider error.
Remaining proof gaps: no real Ghidra run; no vendor-shipped signed
.ldefsfile is known (the issue used a controlled fixture).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
Host: Windows 11, Node.js 24.21.0.
npm run test:local -- src/ghidra/GhidraLanguageOverride.test.ts: the new test and all catalog tests pass. Four profile tests in this file (commits the configured language…,records the language default…,keeps header auto-detection…,refuses an undefined compiler spec…) fail identically on the unmodified base revision on Windows; they are unrelated to this change.npm run check: passed.npm run verify:test-discovery: passed.Compatibility, safety, and release
Before merge
type(scope): outcome.🤖 Generated with Claude Code