mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-19 22:58:07 +02:00
Merge pull request #17795 from calixteman/issue17794
Don't render corrupted inlined images
This commit is contained in:
commit
10305bf181
3 changed files with 40 additions and 21 deletions
|
@ -739,27 +739,36 @@ class PartialEvaluator {
|
|||
!dict.has("Mask") &&
|
||||
w + h < SMALL_IMAGE_DIMENSIONS
|
||||
) {
|
||||
const imageObj = new PDFImage({
|
||||
xref: this.xref,
|
||||
res: resources,
|
||||
image,
|
||||
isInline,
|
||||
pdfFunctionFactory: this._pdfFunctionFactory,
|
||||
localColorSpaceCache,
|
||||
});
|
||||
// We force the use of RGBA_32BPP images here, because we can't handle
|
||||
// any other kind.
|
||||
imgData = await imageObj.createImageData(
|
||||
/* forceRGBA = */ true,
|
||||
/* isOffscreenCanvasSupported = */ false
|
||||
);
|
||||
operatorList.isOffscreenCanvasSupported =
|
||||
this.options.isOffscreenCanvasSupported;
|
||||
operatorList.addImageOps(
|
||||
OPS.paintInlineImageXObject,
|
||||
[imgData],
|
||||
optionalContent
|
||||
);
|
||||
try {
|
||||
const imageObj = new PDFImage({
|
||||
xref: this.xref,
|
||||
res: resources,
|
||||
image,
|
||||
isInline,
|
||||
pdfFunctionFactory: this._pdfFunctionFactory,
|
||||
localColorSpaceCache,
|
||||
});
|
||||
// We force the use of RGBA_32BPP images here, because we can't handle
|
||||
// any other kind.
|
||||
imgData = await imageObj.createImageData(
|
||||
/* forceRGBA = */ true,
|
||||
/* isOffscreenCanvasSupported = */ false
|
||||
);
|
||||
operatorList.isOffscreenCanvasSupported =
|
||||
this.options.isOffscreenCanvasSupported;
|
||||
operatorList.addImageOps(
|
||||
OPS.paintInlineImageXObject,
|
||||
[imgData],
|
||||
optionalContent
|
||||
);
|
||||
} catch (reason) {
|
||||
const msg = `Unable to decode inline image: "${reason}".`;
|
||||
|
||||
if (!this.options.ignoreErrors) {
|
||||
throw new Error(msg);
|
||||
}
|
||||
warn(msg);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
2
test/pdfs/issue17794.pdf.link
Normal file
2
test/pdfs/issue17794.pdf.link
Normal file
|
@ -0,0 +1,2 @@
|
|||
https://github.com/mozilla/pdf.js/files/14607428/image1.pdf
|
||||
|
|
@ -9771,5 +9771,13 @@
|
|||
"rounds": 1,
|
||||
"annotations": true,
|
||||
"type": "eq"
|
||||
},
|
||||
{
|
||||
"id": "issue17794",
|
||||
"file": "pdfs/issue17794.pdf",
|
||||
"md5": "a66b5b938cb44ae241cad845cc3b5d2d",
|
||||
"rounds": 1,
|
||||
"link": true,
|
||||
"type": "eq"
|
||||
}
|
||||
]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue