diff --git a/src/core/annotation.js b/src/core/annotation.js index 1bb949afe..4962e791a 100644 --- a/src/core/annotation.js +++ b/src/core/annotation.js @@ -1970,11 +1970,12 @@ class WidgetAnnotation extends Annotation { */ _decodeFormValue(formValue) { if (Array.isArray(formValue)) { - return formValue - .filter(item => typeof item === "string") - .map(item => stringToPDFString(item)); + const arr = formValue + .map(item => this._decodeFormValue(item)) + .filter(item => item !== null); + return arr.length > 0 ? arr : null; } else if (formValue instanceof Name) { - return stringToPDFString(formValue.name); + return formValue.name; } else if (typeof formValue === "string") { return stringToPDFString(formValue); } @@ -3419,7 +3420,8 @@ class ButtonWidgetAnnotation extends WidgetAnnotation { ? this.data.fieldValue : "Yes"; - const exportValues = this._decodeFormValue([...normalAppearance.getKeys()]); + // Don't decode the keys which are names. + const exportValues = [...normalAppearance.getKeys()]; if (exportValues.length === 0) { exportValues.push("Off", yes); } else if (exportValues.length === 1) { @@ -3491,7 +3493,7 @@ class ButtonWidgetAnnotation extends WidgetAnnotation { } for (const key of normalAppearance.getKeys()) { if (key !== "Off") { - this.data.buttonValue = this._decodeFormValue(key); + this.data.buttonValue = key; break; } } diff --git a/test/pdfs/bug2022700.pdf.link b/test/pdfs/bug2022700.pdf.link new file mode 100644 index 000000000..7d43d46c2 --- /dev/null +++ b/test/pdfs/bug2022700.pdf.link @@ -0,0 +1 @@ +https://bugzilla.mozilla.org/attachment.cgi?id=9552059 diff --git a/test/test_manifest.json b/test/test_manifest.json index 25a605031..7c8ca335e 100644 --- a/test/test_manifest.json +++ b/test/test_manifest.json @@ -14143,5 +14143,22 @@ "md5": "29c23022ab3d983733e1ee37fd0bc785", "rounds": 1, "type": "eq" + }, + { + "id": "bug2022700", + "file": "pdfs/bug2022700.pdf", + "md5": "27c147191aa76a9f9916b3ede76a9523", + "link": true, + "rounds": 1, + "firstPage": 1, + "lastPage": 1, + "save": true, + "print": true, + "annotationStorage": { + "35R": { + "value": true + } + }, + "type": "eq" } ] diff --git a/test/unit/annotation_spec.js b/test/unit/annotation_spec.js index 28a5a9c27..cf364a521 100644 --- a/test/unit/annotation_spec.js +++ b/test/unit/annotation_spec.js @@ -2930,10 +2930,11 @@ describe("annotation", function () { it("should handle radio buttons with a field value that's not an ASCII string", async function () { const parentDict = new Dict(); - parentDict.set("V", Name.get("\x91I=\x91\xf0\x93\xe0\x97e3")); + const name = "\x91I=\x91\xf0\x93\xe0\x97e3"; + parentDict.set("V", Name.get(name)); const normalAppearanceStateDict = new Dict(); - normalAppearanceStateDict.set("\x91I=\x91\xf0\x93\xe0\x97e3", null); + normalAppearanceStateDict.set(name, null); const appearanceStatesDict = new Dict(); appearanceStatesDict.set("N", normalAppearanceStateDict); @@ -2956,8 +2957,8 @@ describe("annotation", function () { expect(data.annotationType).toEqual(AnnotationType.WIDGET); expect(data.checkBox).toEqual(false); expect(data.radioButton).toEqual(true); - expect(data.fieldValue).toEqual("‚I=‚ðfiàŠe3"); - expect(data.buttonValue).toEqual("‚I=‚ðfiàŠe3"); + expect(data.fieldValue).toEqual(name); + expect(data.buttonValue).toEqual(name); }); it("should handle radio buttons without a field value", async function () {