mirror of
https://github.com/mozilla/pdf.js.git
synced 2026-06-29 03:35:47 +02:00
Merge pull request #21137 from calixteman/bug2022700
Don't decode name of the checkboxes exported values (bug 2022700)
This commit is contained in:
commit
2674a9f3e4
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
1
test/pdfs/bug2022700.pdf.link
Normal file
1
test/pdfs/bug2022700.pdf.link
Normal file
@ -0,0 +1 @@
|
||||
https://bugzilla.mozilla.org/attachment.cgi?id=9552059
|
||||
@ -14151,5 +14151,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"
|
||||
}
|
||||
]
|
||||
|
||||
@ -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 () {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user