Ensure that the /Resources-entry is actually a dictionary (issue 15150)
Prevent issues in *corrupt* PDF documents, if the /Resources-entry is not of the correct and expected type.
This commit is contained in:
parent
b0a3c9e8cf
commit
c2f7942aea
@ -132,10 +132,12 @@ class Page {
|
|||||||
// For robustness: The spec states that a \Resources entry has to be
|
// For robustness: The spec states that a \Resources entry has to be
|
||||||
// present, but can be empty. Some documents still omit it; in this case
|
// present, but can be empty. Some documents still omit it; in this case
|
||||||
// we return an empty dictionary.
|
// we return an empty dictionary.
|
||||||
|
const resources = this._getInheritableProperty("Resources");
|
||||||
|
|
||||||
return shadow(
|
return shadow(
|
||||||
this,
|
this,
|
||||||
"resources",
|
"resources",
|
||||||
this._getInheritableProperty("Resources") || Dict.empty
|
resources instanceof Dict ? resources : Dict.empty
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
1
test/pdfs/.gitignore
vendored
1
test/pdfs/.gitignore
vendored
@ -509,6 +509,7 @@
|
|||||||
!poppler-67295-0.pdf
|
!poppler-67295-0.pdf
|
||||||
!poppler-85140-0.pdf
|
!poppler-85140-0.pdf
|
||||||
!issue15012.pdf
|
!issue15012.pdf
|
||||||
|
!issue15150.pdf
|
||||||
!poppler-395-0-fuzzed.pdf
|
!poppler-395-0-fuzzed.pdf
|
||||||
!GHOSTSCRIPT-698804-1-fuzzed.pdf
|
!GHOSTSCRIPT-698804-1-fuzzed.pdf
|
||||||
!issue14814.pdf
|
!issue14814.pdf
|
||||||
|
24
test/pdfs/issue15150.pdf
Normal file
24
test/pdfs/issue15150.pdf
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
%PDF-1.4
|
||||||
|
1 0 obj <</Type /Catalog /Pages 2 0 R>>
|
||||||
|
endobj
|
||||||
|
2 0 obj <</Type /Pages /Kids [3 0 R] /Count 1>>
|
||||||
|
endobj
|
||||||
|
3 0 obj<</Type /Page /Parent 2 0 R /Resources 4 0 R /MediaBox [0 0 10 10] /Contents 4 0 R>>
|
||||||
|
endobj
|
||||||
|
4 0 obj
|
||||||
|
<</Length 12>>
|
||||||
|
stream
|
||||||
|
0.5 w 1 0 0 RG 0 9.75 m 0.5 9.75 l s
|
||||||
|
endstream
|
||||||
|
endobj
|
||||||
|
xref
|
||||||
|
0 5
|
||||||
|
0000000000 65535 f
|
||||||
|
0000000009 00000 n
|
||||||
|
0000000056 00000 n
|
||||||
|
0000000111 00000 n
|
||||||
|
0000000210 00000 n
|
||||||
|
trailer <</Size 5/Root 1 0 R>>
|
||||||
|
startxref
|
||||||
|
294
|
||||||
|
%%EOF
|
@ -673,6 +673,38 @@ describe("api", function () {
|
|||||||
|
|
||||||
await Promise.all([loadingTask1.destroy(), loadingTask2.destroy()]);
|
await Promise.all([loadingTask1.destroy(), loadingTask2.destroy()]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("creates pdf doc from PDF file with bad /Resources entry", async function () {
|
||||||
|
const loadingTask = getDocument(buildGetDocumentParams("issue15150.pdf"));
|
||||||
|
expect(loadingTask instanceof PDFDocumentLoadingTask).toEqual(true);
|
||||||
|
|
||||||
|
const pdfDocument = await loadingTask.promise;
|
||||||
|
expect(pdfDocument.numPages).toEqual(1);
|
||||||
|
|
||||||
|
const page = await pdfDocument.getPage(1);
|
||||||
|
expect(page instanceof PDFPageProxy).toEqual(true);
|
||||||
|
|
||||||
|
const opList = await page.getOperatorList();
|
||||||
|
expect(opList.fnArray).toEqual([
|
||||||
|
OPS.setLineWidth,
|
||||||
|
OPS.setStrokeRGBColor,
|
||||||
|
OPS.constructPath,
|
||||||
|
OPS.closeStroke,
|
||||||
|
]);
|
||||||
|
expect(opList.argsArray).toEqual([
|
||||||
|
[0.5],
|
||||||
|
new Uint8ClampedArray([255, 0, 0]),
|
||||||
|
[
|
||||||
|
[OPS.moveTo, OPS.lineTo],
|
||||||
|
[0, 9.75, 0.5, 9.75],
|
||||||
|
[0, 0.5, 9.75, 9.75],
|
||||||
|
],
|
||||||
|
null,
|
||||||
|
]);
|
||||||
|
expect(opList.lastChunk).toEqual(true);
|
||||||
|
|
||||||
|
await loadingTask.destroy();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("PDFWorker", function () {
|
describe("PDFWorker", function () {
|
||||||
|
Loading…
Reference in New Issue
Block a user