diff --git a/src/core/xfa/som.js b/src/core/xfa/som.js index 1bc1cd60c..472b8306d 100644 --- a/src/core/xfa/som.js +++ b/src/core/xfa/som.js @@ -313,7 +313,7 @@ function createDataNode(root, container, expr) { } root = child; } else { - parsed[i].index = children.length - index; + parsed[i].index = index - children.length; return createNodes(root, parsed.slice(i)); } } diff --git a/src/core/xfa/template.js b/src/core/xfa/template.js index b6467ca3d..5fa05df53 100644 --- a/src/core/xfa/template.js +++ b/src/core/xfa/template.js @@ -2396,9 +2396,15 @@ class Field extends XFAObject { if (this.ui.imageEdit) { ui.children.push(this.value[$toHTML]().html); } else if (!this.ui.button) { - const value = this.value.exData - ? this.value.exData[$text]() - : this.value[$toHTML]().html.value; + let value = ""; + if (this.value.exData) { + value = this.value.exData[$text](); + } else { + const htmlValue = this.value[$toHTML]().html; + if (htmlValue !== null) { + value = htmlValue.value; + } + } if (value) { if (ui.children[0].name === "textarea") { ui.children[0].attributes.textContent = value; diff --git a/test/pdfs/xfa_issue13556.pdf.link b/test/pdfs/xfa_issue13556.pdf.link new file mode 100644 index 000000000..c9964f9be --- /dev/null +++ b/test/pdfs/xfa_issue13556.pdf.link @@ -0,0 +1 @@ +https://web.archive.org/web/20210422084343/https://mail.gnome.org/archives/evince-list/2013-November/pdfNC0hkVW67a.pdf diff --git a/test/test_manifest.json b/test/test_manifest.json index 8e97d7a3c..957837e9e 100644 --- a/test/test_manifest.json +++ b/test/test_manifest.json @@ -938,6 +938,14 @@ "enableXfa": true, "type": "eq" }, + { "id": "xfa_issue13556", + "file": "pdfs/xfa_issue13556.pdf", + "md5": "197e93a010763c3b6f9845595ee66c70", + "link": true, + "rounds": 1, + "enableXfa": true, + "type": "eq" + }, { "id": "xfa_issue13213", "file": "pdfs/xfa_issue13213.pdf", "md5": "8a0e3179bffbac721589d1b1df863b49",