Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure that PDFImage.buildImage won't accidentally swallow errors, e.g. from ColorSpace parsing (issue 6707, PR 11601 follow-up) #12000

Merged
merged 1 commit into from
Jun 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/core/evaluator.js
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
return this._sendImgData(objId, imgData, cacheGlobally);
})
.catch(reason => {
warn("Unable to decode image: " + reason);
warn(`Unable to decode image "${objId}": "${reason}".`);

return this._sendImgData(objId, /* imgData = */ null, cacheGlobally);
});
Expand Down
23 changes: 11 additions & 12 deletions src/core/image.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ var PDFImage = (function PDFImageClosure() {
* Handles processing of image data and returns the Promise that is resolved
* with a PDFImage when the image is ready to be used.
*/
PDFImage.buildImage = function ({
PDFImage.buildImage = async function ({
xref,
res,
image,
Expand All @@ -271,17 +271,16 @@ var PDFImage = (function PDFImageClosure() {
warn("Unsupported mask format.");
}
}
return Promise.resolve(
new PDFImage({
xref,
res,
image: imageData,
isInline,
smask: smaskData,
mask: maskData,
pdfFunctionFactory,
})
);

return new PDFImage({
xref,
res,
image: imageData,
isInline,
smask: smaskData,
mask: maskData,
pdfFunctionFactory,
});
};

PDFImage.createMask = function ({
Expand Down
1 change: 1 addition & 0 deletions test/pdfs/issue6707.pdf.link
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
https://web.archive.org/web/20151201202008/https://secure.dynaccount.com/data/voucher/30000/400/30452_93e074c4c8b2301a24b33176331c49e5755e02fa.pdf
8 changes: 8 additions & 0 deletions test/test_manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -669,6 +669,14 @@
"lastPage": 1,
"type": "eq"
},
{ "id": "issue6707",
"file": "pdfs/issue6707.pdf",
"md5": "068ceaec23d265b1d38dfa6ab279f017",
"rounds": 1,
"link": true,
"lastPage": 1,
"type": "eq"
},
{ "id": "issue6721_reduced",
"file": "pdfs/issue6721_reduced.pdf",
"md5": "719aa66d8081a15e3ba6032ed4279237",
Expand Down