1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-22 16:18:08 +02:00

Don't render corrupted inlined images

Fixes #17794.
This commit is contained in:
Calixte Denizet 2024-03-14 21:23:26 +01:00
parent 30e69956db
commit 9c3471dd01
3 changed files with 40 additions and 21 deletions

View file

@ -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;
}