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.
|
||||
// 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);
|
||||
if (!match) {
|
||||
// For example if the node contains a .(...) then it isn't
|
||||
// findable.
|
||||
// TODO: remove this when .(...) is implemented.
|
||||
continue;
|
||||
}
|
||||
if (this._isConsumeData()) {
|
||||
match[$consumed] = true;
|
||||
}
|
||||
|
@ -60,7 +60,10 @@ function parseIndex(index) {
|
||||
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);
|
||||
if (!match) {
|
||||
return null;
|
||||
@ -108,10 +111,22 @@ function parseExpression(expr, dotDotAllowed) {
|
||||
operator = operators.dotHash;
|
||||
break;
|
||||
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
|
||||
operator = operators.dotBracket;
|
||||
break;
|
||||
case "(":
|
||||
if (noExpr) {
|
||||
warn(
|
||||
"XFA - SOM expression contains a JavaScript subexpression which is not supported for now."
|
||||
);
|
||||
return null;
|
||||
}
|
||||
// TODO:
|
||||
// Javascript expression: should be a boolean operation with a path
|
||||
// so maybe we can have our own parser for that stuff or
|
||||
|
@ -172,6 +172,9 @@ function handleBreak(node) {
|
||||
let target = null;
|
||||
if (node.target) {
|
||||
target = root[$searchNode](node.target, node[$getParent]());
|
||||
if (!target) {
|
||||
return false;
|
||||
}
|
||||
target = target ? target[0] : target;
|
||||
}
|
||||
|
||||
@ -197,12 +200,12 @@ function handleBreak(node) {
|
||||
target = null;
|
||||
}
|
||||
|
||||
const pageArea = target[$getParent]();
|
||||
const contentAreas = pageArea.contentArea.children;
|
||||
const pageArea = target && target[$getParent]();
|
||||
|
||||
let index;
|
||||
if (node.startNew) {
|
||||
if (target) {
|
||||
const contentAreas = pageArea.contentArea.children;
|
||||
index = contentAreas.findIndex(e => e === target) - 1;
|
||||
} else {
|
||||
index = currentPageArea.contentArea.children.findIndex(
|
||||
@ -210,6 +213,7 @@ function handleBreak(node) {
|
||||
);
|
||||
}
|
||||
} else if (target && target !== currentContentArea) {
|
||||
const contentAreas = pageArea.contentArea.children;
|
||||
index = contentAreas.findIndex(e => e === target) - 1;
|
||||
} else {
|
||||
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,
|
||||
"type": "eq"
|
||||
},
|
||||
{ "id": "xfa_bug17176688_1",
|
||||
{ "id": "xfa_bug1717668_1",
|
||||
"file": "pdfs/xfa_bug1717668_1.pdf",
|
||||
"md5": "564ecff67be690b43c2a144ae5967034",
|
||||
"link": true,
|
||||
@ -1002,7 +1002,7 @@
|
||||
"enableXfa": true,
|
||||
"type": "eq"
|
||||
},
|
||||
{ "id": "xfa_bug17176688_2",
|
||||
{ "id": "xfa_bug1717668_2",
|
||||
"file": "pdfs/xfa_bug1717668_2.pdf",
|
||||
"md5": "08aa8bf9fec5aa7b8ff13d9ba72ca8ac",
|
||||
"link": true,
|
||||
@ -1010,7 +1010,7 @@
|
||||
"enableXfa": true,
|
||||
"type": "eq"
|
||||
},
|
||||
{ "id": "xfa_bug17176688_3",
|
||||
{ "id": "xfa_bug1717668_3",
|
||||
"file": "pdfs/xfa_bug1717668_3.pdf",
|
||||
"md5": "4ff2531dbefebabc3f128d4ae20552a4",
|
||||
"link": true,
|
||||
@ -1018,6 +1018,14 @@
|
||||
"enableXfa": true,
|
||||
"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",
|
||||
"file": "pdfs/xfa_bug1718037.pdf",
|
||||
"md5": "a0b53d50e9faed9d57950a5159d5da12",
|
||||
|
Loading…
Reference in New Issue
Block a user