Save form data in XFA datasets when pdf is a mix of acroforms and xfa (#12344)

* Move display/xml_parser.js in shared to use it in worker

* Save form data in XFA datasets when pdf is a mix of acroforms and xfa

Co-authored-by: Brendan Dahl <brendan.dahl@gmail.com>
This commit is contained in:
calixteman 2020-09-09 00:13:52 +02:00 committed by GitHub
parent 622e2fbd3a
commit 68b99c59ee
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 416 additions and 19 deletions

View file

@ -17,6 +17,7 @@ import {
bytesToString,
createPromiseCapability,
createValidAbsoluteUrl,
encodeToXmlString,
escapeString,
getModificationDate,
isArrayBuffer,
@ -24,6 +25,7 @@ import {
isNum,
isSameOrigin,
isString,
parseXFAPath,
removeNullCharacters,
string32,
stringToBytes,
@ -331,4 +333,32 @@ describe("util", function () {
expect(getModificationDate(date)).toEqual("31410610020653");
});
});
describe("parseXFAPath", function () {
it("should get a correctly parsed path", function () {
const path = "foo.bar[12].oof[3].rab.FOO[123].BAR[456]";
expect(parseXFAPath(path)).toEqual([
{ name: "foo", pos: 0 },
{ name: "bar", pos: 12 },
{ name: "oof", pos: 3 },
{ name: "rab", pos: 0 },
{ name: "FOO", pos: 123 },
{ name: "BAR", pos: 456 },
]);
});
});
describe("encodeToXmlString", function () {
it("should get a correctly encoded string with some entities", function () {
const str = "\"\u0397ell😂' & <W😂rld>";
expect(encodeToXmlString(str)).toEqual(
"&quot;&#x397;ell&#x1F602;&apos; &amp; &lt;W&#x1F602;rld&gt;"
);
});
it("should get a correctly encoded basic ascii string", function () {
const str = "hello world";
expect(encodeToXmlString(str)).toEqual(str);
});
});
});