fix(ghidra): read UTF-8 signed language definitions (#2772)
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 #2533 Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
8823c55b0c
commit
ec4f4ddc58
@@ -75,8 +75,10 @@ export const readGhidraLanguageCatalog = async (
|
||||
if (!entry.endsWith(".ldefs")) continue;
|
||||
const bytes = await readFile(join(directory, entry));
|
||||
if (bytes.length > MAX_LDEFS_BYTES) continue;
|
||||
// XML 1.0 section 4.3.3: a leading UTF-8 BOM is an encoding signature,
|
||||
// not document content; TextDecoder consumes it, Buffer#toString does not.
|
||||
definitions.push(
|
||||
...parseGhidraLanguageDefinitions(bytes.toString("utf8")),
|
||||
...parseGhidraLanguageDefinitions(new TextDecoder().decode(bytes)),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user