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

Adjust the heuristics for handling of incomplete path operators (issue 14917) #14921

Merged
merged 1 commit into from
May 15, 2022
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
11 changes: 9 additions & 2 deletions src/core/evaluator.js
Original file line number Diff line number Diff line change
Expand Up @@ -4765,6 +4765,7 @@ class EvaluatorPreprocessor {
});
this.stateManager = stateManager;
this.nonProcessedArgs = [];
this._isPathOp = false;
this._numInvalidPathOPS = 0;
}

Expand Down Expand Up @@ -4810,6 +4811,13 @@ class EvaluatorPreprocessor {
const numArgs = opSpec.numArgs;
let argsLength = args !== null ? args.length : 0;

// If the *previous* command wasn't a path operator, reset the heuristic
// used with incomplete path operators below (fixes issue14917.pdf).
if (!this._isPathOp) {
this._numInvalidPathOPS = 0;
}
this._isPathOp = fn >= OPS.moveTo && fn <= OPS.endPath;

if (!opSpec.variableArgs) {
// Postscript commands can be nested, e.g. /F2 /GS2 gs 5.711 Tf
if (argsLength !== numArgs) {
Expand Down Expand Up @@ -4837,8 +4845,7 @@ class EvaluatorPreprocessor {
// used to error, rather than just warn, once a number of invalid
// path operators have been encountered (fixes bug1443140.pdf).
if (
fn >= OPS.moveTo &&
fn <= OPS.endPath && // Path operator
this._isPathOp &&
++this._numInvalidPathOPS >
EvaluatorPreprocessor.MAX_INVALID_PATH_OPS
) {
Snuffleupagus marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
1 change: 1 addition & 0 deletions test/pdfs/issue14917.pdf.link
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
https://web.archive.org/web/20220515091440/https://pdf.cdn.readpaper.com/spd/2963250244.pdf
8 changes: 8 additions & 0 deletions test/test_manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3016,6 +3016,14 @@
},
"about": "Need to test *at least* three pages, since the `GlobalImageCache` is involved."
},
{ "id": "issue14917",
"file": "pdfs/issue14917.pdf",
"md5": "12201b35853f78a501ac46b91608f8b6",
"rounds": 1,
"link": true,
"lastPage": 1,
"type": "eq"
},
{ "id": "issue1127-text",
"file": "pdfs/issue1127.pdf",
"md5": "4fb2be5ffefeafda4ba977de2a1bb4d8",
Expand Down