Merge pull request #21481 from Snuffleupagus/metadata-isDict

Use the `isDict` helper in the `Catalog.prototype.metadata` getter
This commit is contained in:
Tim van der Meij 2026-06-21 19:10:54 +02:00 committed by GitHub
commit 38daede697
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -279,11 +279,11 @@ class Catalog {
/* suppressEncryption = */ !this.xref.encrypt?.encryptMetadata
);
if (stream instanceof BaseStream && stream.dict instanceof Dict) {
const type = stream.dict.get("Type");
const subtype = stream.dict.get("Subtype");
if (isName(type, "Metadata") && isName(subtype, "XML")) {
if (
stream instanceof BaseStream &&
isDict(stream.dict, "Metadata") &&
isName(stream.dict.get("Subtype"), "XML")
) {
// XXX: This should examine the charset the XML document defines,
// however since there are currently no real means to decode arbitrary
// charsets, let's just hope that the author of the PDF was reasonable
@ -293,7 +293,6 @@ class Catalog {
metadata = new MetadataParser(data).serializable;
}
}
}
} catch (ex) {
if (ex instanceof MissingDataException) {
throw ex;