1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-22 08:08:07 +02:00

XFA - CDATA can be xml so parse it when required

This commit is contained in:
Calixte Denizet 2021-06-06 16:28:22 +02:00
parent 1775d5eeb7
commit 5dc7f4ade8
4 changed files with 52 additions and 0 deletions

View file

@ -256,6 +256,38 @@ describe("XFAParser", function () {
expect(root[$dump]()).toEqual(expected);
});
it("should parse a xfa document and parse CDATA when needed", function () {
const xml = `
<?xml version="1.0"?>
<xdp:xdp xmlns:xdp="http://ns.adobe.com/xdp/">
<template xmlns="http://www.xfa.org/schema/xfa-template/3.3">
<subform>
<field>
<extras>
<exData contentType="text/html" name="foo">
<![CDATA[<body xmlns="http://www.w3.org/1999/xhtml">
<span>hello</span></body>]]>
</exData>
</extra>
</field>
</subform>
</template>
</xdp:xdp>
`;
const root = new XFAParser().parse(xml);
const exdata = searchNode(root, root, "foo")[0];
const body = exdata[$dump]().$content[$dump]();
const expected = {
$name: "body",
attributes: {},
children: [
{ $content: "hello", $name: "span", attributes: {}, children: [] },
],
};
expect(body).toEqual(expected);
});
it("should parse a xfa document and apply some prototypes", function () {
const xml = `
<?xml version="1.0"?>