XFA - Don't fail xfa loading because of a JS subexpression in SOM expressions
- Fix for one pdf in bug 1717668 (PDFIUM-292-0.pdf).
This commit is contained in:
parent
a0aff125dd
commit
0486d24e36
@ -545,6 +545,12 @@ class Binder {
|
|||||||
// to have something to match with the given expression.
|
// to have something to match with the given expression.
|
||||||
// See http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.364.2157&rep=rep1&type=pdf#page=199
|
// See http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.364.2157&rep=rep1&type=pdf#page=199
|
||||||
match = createDataNode(this.data, dataNode, ref);
|
match = createDataNode(this.data, dataNode, ref);
|
||||||
|
if (!match) {
|
||||||
|
// For example if the node contains a .(...) then it isn't
|
||||||
|
// findable.
|
||||||
|
// TODO: remove this when .(...) is implemented.
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (this._isConsumeData()) {
|
if (this._isConsumeData()) {
|
||||||
match[$consumed] = true;
|
match[$consumed] = true;
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,10 @@ function parseIndex(index) {
|
|||||||
return parseInt(index, 10) || 0;
|
return parseInt(index, 10) || 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseExpression(expr, dotDotAllowed) {
|
// For now expressions containaing .[...] or .(...) are not
|
||||||
|
// evaluated so don't parse them.
|
||||||
|
// TODO: implement that stuff and the remove the noExpr param.
|
||||||
|
function parseExpression(expr, dotDotAllowed, noExpr = true) {
|
||||||
let match = expr.match(namePattern);
|
let match = expr.match(namePattern);
|
||||||
if (!match) {
|
if (!match) {
|
||||||
return null;
|
return null;
|
||||||
@ -108,10 +111,22 @@ function parseExpression(expr, dotDotAllowed) {
|
|||||||
operator = operators.dotHash;
|
operator = operators.dotHash;
|
||||||
break;
|
break;
|
||||||
case "[":
|
case "[":
|
||||||
|
if (noExpr) {
|
||||||
|
warn(
|
||||||
|
"XFA - SOM expression contains a FormCalc subexpression which is not supported for now."
|
||||||
|
);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
// TODO: FormCalc expression so need to use the parser
|
// TODO: FormCalc expression so need to use the parser
|
||||||
operator = operators.dotBracket;
|
operator = operators.dotBracket;
|
||||||
break;
|
break;
|
||||||
case "(":
|
case "(":
|
||||||
|
if (noExpr) {
|
||||||
|
warn(
|
||||||
|
"XFA - SOM expression contains a JavaScript subexpression which is not supported for now."
|
||||||
|
);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
// TODO:
|
// TODO:
|
||||||
// Javascript expression: should be a boolean operation with a path
|
// Javascript expression: should be a boolean operation with a path
|
||||||
// so maybe we can have our own parser for that stuff or
|
// so maybe we can have our own parser for that stuff or
|
||||||
|
@ -172,6 +172,9 @@ function handleBreak(node) {
|
|||||||
let target = null;
|
let target = null;
|
||||||
if (node.target) {
|
if (node.target) {
|
||||||
target = root[$searchNode](node.target, node[$getParent]());
|
target = root[$searchNode](node.target, node[$getParent]());
|
||||||
|
if (!target) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
target = target ? target[0] : target;
|
target = target ? target[0] : target;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -197,12 +200,12 @@ function handleBreak(node) {
|
|||||||
target = null;
|
target = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const pageArea = target[$getParent]();
|
const pageArea = target && target[$getParent]();
|
||||||
const contentAreas = pageArea.contentArea.children;
|
|
||||||
|
|
||||||
let index;
|
let index;
|
||||||
if (node.startNew) {
|
if (node.startNew) {
|
||||||
if (target) {
|
if (target) {
|
||||||
|
const contentAreas = pageArea.contentArea.children;
|
||||||
index = contentAreas.findIndex(e => e === target) - 1;
|
index = contentAreas.findIndex(e => e === target) - 1;
|
||||||
} else {
|
} else {
|
||||||
index = currentPageArea.contentArea.children.findIndex(
|
index = currentPageArea.contentArea.children.findIndex(
|
||||||
@ -210,6 +213,7 @@ function handleBreak(node) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else if (target && target !== currentContentArea) {
|
} else if (target && target !== currentContentArea) {
|
||||||
|
const contentAreas = pageArea.contentArea.children;
|
||||||
index = contentAreas.findIndex(e => e === target) - 1;
|
index = contentAreas.findIndex(e => e === target) - 1;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
|
1
test/pdfs/xfa_bug1717668_4.pdf.link
Normal file
1
test/pdfs/xfa_bug1717668_4.pdf.link
Normal file
@ -0,0 +1 @@
|
|||||||
|
https://bugzilla.mozilla.org/attachment.cgi?id=9229381
|
@ -994,7 +994,7 @@
|
|||||||
"enableXfa": true,
|
"enableXfa": true,
|
||||||
"type": "eq"
|
"type": "eq"
|
||||||
},
|
},
|
||||||
{ "id": "xfa_bug17176688_1",
|
{ "id": "xfa_bug1717668_1",
|
||||||
"file": "pdfs/xfa_bug1717668_1.pdf",
|
"file": "pdfs/xfa_bug1717668_1.pdf",
|
||||||
"md5": "564ecff67be690b43c2a144ae5967034",
|
"md5": "564ecff67be690b43c2a144ae5967034",
|
||||||
"link": true,
|
"link": true,
|
||||||
@ -1002,7 +1002,7 @@
|
|||||||
"enableXfa": true,
|
"enableXfa": true,
|
||||||
"type": "eq"
|
"type": "eq"
|
||||||
},
|
},
|
||||||
{ "id": "xfa_bug17176688_2",
|
{ "id": "xfa_bug1717668_2",
|
||||||
"file": "pdfs/xfa_bug1717668_2.pdf",
|
"file": "pdfs/xfa_bug1717668_2.pdf",
|
||||||
"md5": "08aa8bf9fec5aa7b8ff13d9ba72ca8ac",
|
"md5": "08aa8bf9fec5aa7b8ff13d9ba72ca8ac",
|
||||||
"link": true,
|
"link": true,
|
||||||
@ -1010,7 +1010,7 @@
|
|||||||
"enableXfa": true,
|
"enableXfa": true,
|
||||||
"type": "eq"
|
"type": "eq"
|
||||||
},
|
},
|
||||||
{ "id": "xfa_bug17176688_3",
|
{ "id": "xfa_bug1717668_3",
|
||||||
"file": "pdfs/xfa_bug1717668_3.pdf",
|
"file": "pdfs/xfa_bug1717668_3.pdf",
|
||||||
"md5": "4ff2531dbefebabc3f128d4ae20552a4",
|
"md5": "4ff2531dbefebabc3f128d4ae20552a4",
|
||||||
"link": true,
|
"link": true,
|
||||||
@ -1018,6 +1018,14 @@
|
|||||||
"enableXfa": true,
|
"enableXfa": true,
|
||||||
"type": "eq"
|
"type": "eq"
|
||||||
},
|
},
|
||||||
|
{ "id": "xfa_bug1717668_4",
|
||||||
|
"file": "pdfs/xfa_bug1717668_4.pdf",
|
||||||
|
"md5": "1c3dc4873ad6b84adb164ed69ed202f5",
|
||||||
|
"link": true,
|
||||||
|
"rounds": 1,
|
||||||
|
"enableXfa": true,
|
||||||
|
"type": "eq"
|
||||||
|
},
|
||||||
{ "id": "xfa_bug1718037",
|
{ "id": "xfa_bug1718037",
|
||||||
"file": "pdfs/xfa_bug1718037.pdf",
|
"file": "pdfs/xfa_bug1718037.pdf",
|
||||||
"md5": "a0b53d50e9faed9d57950a5159d5da12",
|
"md5": "a0b53d50e9faed9d57950a5159d5da12",
|
||||||
|
Loading…
Reference in New Issue
Block a user