1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-29 07:37:57 +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:
Calixte Denizet 2021-07-07 10:32:53 +02:00
parent a0aff125dd
commit 0486d24e36
5 changed files with 40 additions and 6 deletions

View file

@ -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