mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-22 16:18:08 +02:00
Prevent Metadata/XML parsing from breaking PDFDocumentProxy.getMetadata
when no XML root document is found (issue 8884)
With the new XML parser, see PR 9573, the referenced PDF file now causes `getMetadata` to fail when incomplete XML tags are encountered. This provides a simple, and hopefully generally useful, work-around that may also help prevent future bugs. (Without being able to reproduce nor even understand the other (non XML) errors mentioned in issue 8884, I'd say that this patch is enough to close that one as fixed.)
This commit is contained in:
parent
7e13977669
commit
8ec99b200c
2 changed files with 34 additions and 0 deletions
|
@ -321,6 +321,9 @@ class SimpleXMLParser extends XMLParserBase {
|
|||
|
||||
// We should only have one root.
|
||||
const [documentElement] = this._currentFragment;
|
||||
if (!documentElement) {
|
||||
return undefined; // Return undefined if no root was found.
|
||||
}
|
||||
return { documentElement, };
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue