mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-20 15:18:08 +02:00
Handle errors when fetching the raw /Metadata (issue 14305)
Currently the `Catalog.metadata` getter only handles errors during parsing, however in a *corrupt* PDF document fetching of the raw /Metadata can obviously fail as well. Without this patch the `PDFDocumentProxy.getMetadata` method, in the API, can thus fail which it *never* should and this will cause the viewer to not initialize all state as expected. Fixes one of the documents in issue 14305.
This commit is contained in:
parent
e9e4b913c0
commit
40291d1943
4 changed files with 3624 additions and 19 deletions
1
test/pdfs/.gitignore
vendored
1
test/pdfs/.gitignore
vendored
|
@ -498,3 +498,4 @@
|
|||
!poppler-91414-0-54.pdf
|
||||
!poppler-742-0-fuzzed.pdf
|
||||
!poppler-937-0-fuzzed.pdf
|
||||
!PDFBOX-3148-2-fuzzed.pdf
|
||||
|
|
3574
test/pdfs/PDFBOX-3148-2-fuzzed.pdf
Normal file
3574
test/pdfs/PDFBOX-3148-2-fuzzed.pdf
Normal file
File diff suppressed because it is too large
Load diff
|
@ -1439,6 +1439,8 @@ describe("api", function () {
|
|||
const { info, metadata, contentDispositionFilename, contentLength } =
|
||||
await pdfDoc.getMetadata();
|
||||
|
||||
// Custom, non-standard, information dictionary entries.
|
||||
expect(info.Custom).toEqual(undefined);
|
||||
// The following are PDF.js specific, non-standard, properties.
|
||||
expect(info.PDFFormatVersion).toEqual(null);
|
||||
expect(info.Language).toEqual(null);
|
||||
|
@ -1456,6 +1458,33 @@ describe("api", function () {
|
|||
await loadingTask.destroy();
|
||||
});
|
||||
|
||||
it("gets metadata, with corrupt /Metadata XRef entry", async function () {
|
||||
const loadingTask = getDocument(
|
||||
buildGetDocumentParams("PDFBOX-3148-2-fuzzed.pdf")
|
||||
);
|
||||
const pdfDoc = await loadingTask.promise;
|
||||
const { info, metadata, contentDispositionFilename, contentLength } =
|
||||
await pdfDoc.getMetadata();
|
||||
|
||||
// Custom, non-standard, information dictionary entries.
|
||||
expect(info.Custom).toEqual(undefined);
|
||||
// The following are PDF.js specific, non-standard, properties.
|
||||
expect(info.PDFFormatVersion).toEqual("1.6");
|
||||
expect(info.Language).toEqual(null);
|
||||
expect(info.EncryptFilterName).toEqual(null);
|
||||
expect(info.IsLinearized).toEqual(false);
|
||||
expect(info.IsAcroFormPresent).toEqual(true);
|
||||
expect(info.IsXFAPresent).toEqual(false);
|
||||
expect(info.IsCollectionPresent).toEqual(false);
|
||||
expect(info.IsSignaturesPresent).toEqual(false);
|
||||
|
||||
expect(metadata).toEqual(null);
|
||||
expect(contentDispositionFilename).toEqual(null);
|
||||
expect(contentLength).toEqual(244351);
|
||||
|
||||
await loadingTask.destroy();
|
||||
});
|
||||
|
||||
it("gets markInfo", async function () {
|
||||
const loadingTask = getDocument(
|
||||
buildGetDocumentParams("annotation-line.pdf")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue