From 5b7e1f5232c6bb42469f0b5aac347af3fb7df244 Mon Sep 17 00:00:00 2001 From: Calixte Denizet Date: Fri, 12 Nov 2021 16:17:02 +0100 Subject: [PATCH] XFA - Avoid an exception when looking for a font in a parent node - it aims to fix issue https://github.com/mozilla/pdf.js/issues/14150; - a parent can be null in case the root has been reached, so just add a check. --- src/core/xfa/html_utils.js | 2 +- test/pdfs/xfa_issue14150.pdf.link | 1 + test/test_manifest.json | 9 +++++++++ 3 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 test/pdfs/xfa_issue14150.pdf.link diff --git a/src/core/xfa/html_utils.js b/src/core/xfa/html_utils.js index 2f850ab37..92897baac 100644 --- a/src/core/xfa/html_utils.js +++ b/src/core/xfa/html_utils.js @@ -238,7 +238,7 @@ function layoutNode(node, availableSpace) { if (!font) { const root = node[$getTemplateRoot](); let parent = node[$getParent](); - while (parent !== root) { + while (parent && parent !== root) { if (parent.font) { font = parent.font; break; diff --git a/test/pdfs/xfa_issue14150.pdf.link b/test/pdfs/xfa_issue14150.pdf.link new file mode 100644 index 000000000..da6a4202e --- /dev/null +++ b/test/pdfs/xfa_issue14150.pdf.link @@ -0,0 +1 @@ +https://github.com/mozilla/pdf.js/files/7528643/dol4n.pdf diff --git a/test/test_manifest.json b/test/test_manifest.json index a1e0f449b..8eea3d06d 100644 --- a/test/test_manifest.json +++ b/test/test_manifest.json @@ -1013,6 +1013,15 @@ "link": true, "type": "load" }, + { "id": "xfa_issue14150", + "file": "pdfs/xfa_issue14150.pdf", + "md5": "295b3e513b62945fbba73bce6908344c", + "link": true, + "rounds": 1, + "enableXfa": true, + "lastPage": 1, + "type": "eq" + }, { "id": "xfa_issue14071", "file": "pdfs/xfa_issue14071.pdf", "md5": "7ef09705091602668ce22086c83a90f3",