From c2fe493abeaeaa0d7e12575eb660367267534486 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Tue, 20 Jul 2021 17:14:20 +0200 Subject: [PATCH] XFA - Add a missing method to `XFAAttribute`, to prevent breaking errors (issue 13748) *This is yet another case where I've got no idea if the patch is correct, but it does at least fix a breaking error :-)* Note how in the [`Binder._bindValue` method](https://github.com/mozilla/pdf.js/blob/683ce66a48cd54fa48e96e1925277c134859e76c/src/core/xfa/bind.js#L92-L93), we're assuming that if a `data`-value exists then it'll also be possible to actually access it. For the `XFAAttribute`-implementation however, the second method is missing and that's what causes the breaking errors in issue 13748. Please note that another possible way of "fixing" the error wouldn't been to simply change the exists-check to return `false`, and I could see that being a preferred solution. However, the reason for submitting the current patch is that we get *fewer* warnings about Nodes with mis-matched types this way. --- src/core/xfa/xfa_object.js | 4 ++++ test/pdfs/issue13748.pdf.link | 1 + test/test_manifest.json | 9 +++++++++ 3 files changed, 14 insertions(+) create mode 100644 test/pdfs/issue13748.pdf.link diff --git a/src/core/xfa/xfa_object.js b/src/core/xfa/xfa_object.js index f0dbaa0e8..8e55e20c9 100644 --- a/src/core/xfa/xfa_object.js +++ b/src/core/xfa/xfa_object.js @@ -745,6 +745,10 @@ class XFAAttribute { return true; } + [$getDataValue]() { + return this[$content].trim(); + } + [$setValue](value) { value = value.value || ""; this[$content] = value.toString(); diff --git a/test/pdfs/issue13748.pdf.link b/test/pdfs/issue13748.pdf.link new file mode 100644 index 000000000..4f4f6bdf1 --- /dev/null +++ b/test/pdfs/issue13748.pdf.link @@ -0,0 +1 @@ +https://github.com/mozilla/pdf.js/files/6849364/IFT-3R.7._v1-1E.pdf diff --git a/test/test_manifest.json b/test/test_manifest.json index 445c97dab..5ff77b568 100644 --- a/test/test_manifest.json +++ b/test/test_manifest.json @@ -1347,6 +1347,15 @@ "link": false, "type": "eq" }, + { "id": "issue13748", + "file": "pdfs/issue13748.pdf", + "md5": "de0e4dde2890b9ff145a3184831bae02", + "link": true, + "rounds": 1, + "lastPage": 1, + "enableXfa": true, + "type": "eq" + }, { "id": "issue13756", "file": "pdfs/issue13756.pdf", "md5": "67040c6df3b5039fcbc81bf63b7c7f98",