mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-20 15:18:08 +02:00
Abort parsing when the XRef /W-array contain bogus entries (issue 14303)
For this particular PDF document, we have `/W [1 2 166666666666666666666666666]` which obviously makes no sense. While this patch makes no attempt at actually validating the entries in the /W-array, we'll now simply abort all processing when the end of the PDF document has been reached (thus preventing hanging the browser). Please note that this patch doesn't enable the PDF document to be loaded/rendered, but at least it fails "correctly" now. Fixes one of the issues listed in issue 14303, namely the `REDHAT-1531897-0.pdf`document.
This commit is contained in:
parent
a2c380ccb3
commit
ca8d2bdce4
4 changed files with 36 additions and 3 deletions
1
test/pdfs/.gitignore
vendored
1
test/pdfs/.gitignore
vendored
|
@ -488,3 +488,4 @@
|
|||
!rc_annotation.pdf
|
||||
!issue14267.pdf
|
||||
!PDFBOX-4352-0.pdf
|
||||
!REDHAT-1531897-0.pdf
|
||||
|
|
BIN
test/pdfs/REDHAT-1531897-0.pdf
Normal file
BIN
test/pdfs/REDHAT-1531897-0.pdf
Normal file
Binary file not shown.
|
@ -458,6 +458,26 @@ describe("api", function () {
|
|||
|
||||
await loadingTask.destroy();
|
||||
});
|
||||
|
||||
it("creates pdf doc from PDF file with bad XRef byteWidths", async function () {
|
||||
// A corrupt PDF file, where the XRef /W-array have (some) bogus entries.
|
||||
const loadingTask = getDocument(
|
||||
buildGetDocumentParams("REDHAT-1531897-0.pdf")
|
||||
);
|
||||
expect(loadingTask instanceof PDFDocumentLoadingTask).toEqual(true);
|
||||
|
||||
try {
|
||||
await loadingTask.promise;
|
||||
|
||||
// Shouldn't get here.
|
||||
expect(false).toEqual(true);
|
||||
} catch (reason) {
|
||||
expect(reason instanceof InvalidPDFException).toEqual(true);
|
||||
expect(reason.message).toEqual("Invalid PDF structure.");
|
||||
}
|
||||
|
||||
await loadingTask.destroy();
|
||||
});
|
||||
});
|
||||
|
||||
describe("PDFWorker", function () {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue