mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-22 16:18:08 +02:00
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
5 changed files with 40 additions and 6 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue