Merge pull request #13761 from Snuffleupagus/issue-13756

XFA - Prevent breaking errors in `Binder`, when `searchNode` doesn't return data (issue 13756)
This commit is contained in:
Jonas Jenwald 2021-07-19 19:38:30 +02:00 committed by GitHub
commit 683ce66a48
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 8 deletions

View File

@ -198,34 +198,36 @@ class Binder {
continue; continue;
} }
const [node] = searchNode( const nodes = searchNode(
this.root, this.root,
dataNode, dataNode,
ref, ref,
false /* = dotDotAllowed */, false /* = dotDotAllowed */,
false /* = useCache */ false /* = useCache */
); );
if (!node) { if (!nodes) {
warn(`XFA - Invalid reference: ${ref}.`); warn(`XFA - Invalid reference: ${ref}.`);
continue; continue;
} }
const [node] = nodes;
if (!node[$isDescendent](this.data)) { if (!node[$isDescendent](this.data)) {
warn(`XFA - Invalid node: must be a data node.`); warn(`XFA - Invalid node: must be a data node.`);
continue; continue;
} }
const [targetNode] = searchNode( const targetNodes = searchNode(
this.root, this.root,
formNode, formNode,
target, target,
false /* = dotDotAllowed */, false /* = dotDotAllowed */,
false /* = useCache */ false /* = useCache */
); );
if (!targetNode) { if (!targetNodes) {
warn(`XFA - Invalid target: ${target}.`); warn(`XFA - Invalid target: ${target}.`);
continue; continue;
} }
const [targetNode] = targetNodes;
if (!targetNode[$isDescendent](formNode)) { if (!targetNode[$isDescendent](formNode)) {
warn(`XFA - Invalid target: must be a property or subproperty.`); warn(`XFA - Invalid target: must be a property or subproperty.`);
@ -337,34 +339,36 @@ class Binder {
continue; continue;
} }
const [labelNode] = searchNode( const labelNodes = searchNode(
this.root, this.root,
node, node,
labelRef, labelRef,
true /* = dotDotAllowed */, true /* = dotDotAllowed */,
false /* = useCache */ false /* = useCache */
); );
if (!labelNode) { if (!labelNodes) {
warn(`XFA - Invalid label: ${labelRef}.`); warn(`XFA - Invalid label: ${labelRef}.`);
continue; continue;
} }
const [labelNode] = labelNodes;
if (!labelNode[$isDescendent](this.datasets)) { if (!labelNode[$isDescendent](this.datasets)) {
warn(`XFA - Invalid label: must be a datasets child.`); warn(`XFA - Invalid label: must be a datasets child.`);
continue; continue;
} }
const [valueNode] = searchNode( const valueNodes = searchNode(
this.root, this.root,
node, node,
valueRef, valueRef,
true /* = dotDotAllowed */, true /* = dotDotAllowed */,
false /* = useCache */ false /* = useCache */
); );
if (!valueNode) { if (!valueNodes) {
warn(`XFA - Invalid value: ${valueRef}.`); warn(`XFA - Invalid value: ${valueRef}.`);
continue; continue;
} }
const [valueNode] = valueNodes;
if (!valueNode[$isDescendent](this.datasets)) { if (!valueNode[$isDescendent](this.datasets)) {
warn(`XFA - Invalid value: must be a datasets child.`); warn(`XFA - Invalid value: must be a datasets child.`);

View File

@ -0,0 +1 @@
https://github.com/mozilla/pdf.js/files/6842290/Attestation_d.occupation.pdf

View File

@ -1347,6 +1347,14 @@
"link": false, "link": false,
"type": "eq" "type": "eq"
}, },
{ "id": "issue13756",
"file": "pdfs/issue13756.pdf",
"md5": "67040c6df3b5039fcbc81bf63b7c7f98",
"link": true,
"rounds": 1,
"enableXfa": true,
"type": "eq"
},
{ "id": "issue9262", { "id": "issue9262",
"file": "pdfs/issue9262_reduced.pdf", "file": "pdfs/issue9262_reduced.pdf",
"md5": "5347ce2d7b3866625c22e115fd90e0de", "md5": "5347ce2d7b3866625c22e115fd90e0de",