Skip to content

Commit 6fb0827

Browse files
Merge pull request #12000 from Snuffleupagus/buildImage-errors
Ensure that `PDFImage.buildImage` won't accidentally swallow errors, e.g. from ColorSpace parsing (issue 6707, PR 11601 follow-up)
2 parents 8f7128d + 4b51bcc commit 6fb0827

File tree

4 files changed

+21
-13
lines changed

4 files changed

+21
-13
lines changed

src/core/evaluator.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
579579
return this._sendImgData(objId, imgData, cacheGlobally);
580580
})
581581
.catch(reason => {
582-
warn("Unable to decode image: " + reason);
582+
warn(`Unable to decode image "${objId}": "${reason}".`);
583583

584584
return this._sendImgData(objId, /* imgData = */ null, cacheGlobally);
585585
});

src/core/image.js

+11-12
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ var PDFImage = (function PDFImageClosure() {
248248
* Handles processing of image data and returns the Promise that is resolved
249249
* with a PDFImage when the image is ready to be used.
250250
*/
251-
PDFImage.buildImage = function ({
251+
PDFImage.buildImage = async function ({
252252
xref,
253253
res,
254254
image,
@@ -271,17 +271,16 @@ var PDFImage = (function PDFImageClosure() {
271271
warn("Unsupported mask format.");
272272
}
273273
}
274-
return Promise.resolve(
275-
new PDFImage({
276-
xref,
277-
res,
278-
image: imageData,
279-
isInline,
280-
smask: smaskData,
281-
mask: maskData,
282-
pdfFunctionFactory,
283-
})
284-
);
274+
275+
return new PDFImage({
276+
xref,
277+
res,
278+
image: imageData,
279+
isInline,
280+
smask: smaskData,
281+
mask: maskData,
282+
pdfFunctionFactory,
283+
});
285284
};
286285

287286
PDFImage.createMask = function ({

test/pdfs/issue6707.pdf.link

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
https://web.archive.org/web/20151201202008/https://secure.dynaccount.com/data/voucher/30000/400/30452_93e074c4c8b2301a24b33176331c49e5755e02fa.pdf

test/test_manifest.json

+8
Original file line numberDiff line numberDiff line change
@@ -669,6 +669,14 @@
669669
"lastPage": 1,
670670
"type": "eq"
671671
},
672+
{ "id": "issue6707",
673+
"file": "pdfs/issue6707.pdf",
674+
"md5": "068ceaec23d265b1d38dfa6ab279f017",
675+
"rounds": 1,
676+
"link": true,
677+
"lastPage": 1,
678+
"type": "eq"
679+
},
672680
{ "id": "issue6721_reduced",
673681
"file": "pdfs/issue6721_reduced.pdf",
674682
"md5": "719aa66d8081a15e3ba6032ed4279237",

0 commit comments

Comments
 (0)