Merge pull request #1486 from yurydelendik/issue-1466
Improving invalid operations syntax recovery (#1466)
This commit is contained in:
commit
449d7105c6
@ -111,6 +111,17 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
|||||||
EX: 'endCompat'
|
EX: 'endCompat'
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function splitCombinedOperations(operations) {
|
||||||
|
// Two operations can be combined together, trying to find which two
|
||||||
|
// operations were concatenated.
|
||||||
|
for (var i = operations.length - 1; i > 0; i--) {
|
||||||
|
var op1 = operations.substring(0, i), op2 = operations.substring(i);
|
||||||
|
if (op1 in OP_MAP && op2 in OP_MAP)
|
||||||
|
return [op1, op2]; // operations found
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
PartialEvaluator.prototype = {
|
PartialEvaluator.prototype = {
|
||||||
getOperatorList: function PartialEvaluator_getOperatorList(stream,
|
getOperatorList: function PartialEvaluator_getOperatorList(stream,
|
||||||
resources,
|
resources,
|
||||||
@ -255,26 +266,32 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
|||||||
var patterns = resources.get('Pattern') || new Dict();
|
var patterns = resources.get('Pattern') || new Dict();
|
||||||
var parser = new Parser(new Lexer(stream), false, xref);
|
var parser = new Parser(new Lexer(stream), false, xref);
|
||||||
var res = resources;
|
var res = resources;
|
||||||
|
var hasNextObj = false, nextObj;
|
||||||
var args = [], obj;
|
var args = [], obj;
|
||||||
var getObjBt = function getObjBt() {
|
|
||||||
parser = this.oldParser;
|
|
||||||
return { name: 'BT' };
|
|
||||||
};
|
|
||||||
var TILING_PATTERN = 1, SHADING_PATTERN = 2;
|
var TILING_PATTERN = 1, SHADING_PATTERN = 2;
|
||||||
|
|
||||||
while (!isEOF(obj = parser.getObj())) {
|
while (true) {
|
||||||
|
if (hasNextObj) {
|
||||||
|
obj = nextObj;
|
||||||
|
hasNextObj = false;
|
||||||
|
} else {
|
||||||
|
obj = parser.getObj();
|
||||||
|
if (isEOF(obj))
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (isCmd(obj)) {
|
if (isCmd(obj)) {
|
||||||
var cmd = obj.cmd;
|
var cmd = obj.cmd;
|
||||||
var fn = OP_MAP[cmd];
|
var fn = OP_MAP[cmd];
|
||||||
if (!fn) {
|
if (!fn) {
|
||||||
// invalid content command, trying to recover
|
// invalid content command, trying to recover
|
||||||
if (cmd.substr(-2) == 'BT') {
|
var cmds = splitCombinedOperations(cmd);
|
||||||
fn = OP_MAP[cmd.substr(0, cmd.length - 2)];
|
if (cmds) {
|
||||||
// feeding 'BT' on next interation
|
cmd = cmds[0];
|
||||||
parser = {
|
fn = OP_MAP[cmd];
|
||||||
getObj: getObjBt,
|
// feeding other command on the next interation
|
||||||
oldParser: parser
|
hasNextObj = true;
|
||||||
};
|
nextObj = Cmd.get(cmds[1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
assertWellFormed(fn, 'Unknown command "' + cmd + '"');
|
assertWellFormed(fn, 'Unknown command "' + cmd + '"');
|
||||||
|
1
test/pdfs/issue1466.pdf.link
Normal file
1
test/pdfs/issue1466.pdf.link
Normal file
@ -0,0 +1 @@
|
|||||||
|
http://web.missouri.edu/~fanxud/publications/On%20the%20performance%20quantification%20of%20resonant%20refractive%20index%20sensors.pdf
|
@ -501,6 +501,13 @@
|
|||||||
"link": true,
|
"link": true,
|
||||||
"type": "eq"
|
"type": "eq"
|
||||||
},
|
},
|
||||||
|
{ "id": "issue1466",
|
||||||
|
"file": "pdfs/issue1466.pdf",
|
||||||
|
"md5": "8a8877432e5bb10cfd50d60488d947bb",
|
||||||
|
"rounds": 1,
|
||||||
|
"link": true,
|
||||||
|
"type": "eq"
|
||||||
|
},
|
||||||
{ "id": "issue1133",
|
{ "id": "issue1133",
|
||||||
"file": "pdfs/issue1133.pdf",
|
"file": "pdfs/issue1133.pdf",
|
||||||
"md5": "d1b61580cb100e3df93d33703af1773a",
|
"md5": "d1b61580cb100e3df93d33703af1773a",
|
||||||
|
Loading…
Reference in New Issue
Block a user