mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-22 16:18:08 +02:00
Merge pull request #13501 from calixteman/13500
XFA - CDATA can be xml so parse it when required
This commit is contained in:
commit
8b4acb4e36
4 changed files with 52 additions and 0 deletions
|
@ -16,7 +16,9 @@
|
|||
import {
|
||||
$acceptWhitespace,
|
||||
$clean,
|
||||
$content,
|
||||
$finalize,
|
||||
$isCDATAXml,
|
||||
$nsAttributes,
|
||||
$onChild,
|
||||
$onText,
|
||||
|
@ -150,6 +152,13 @@ class XFAParser extends XMLParserBase {
|
|||
|
||||
onEndElement(name) {
|
||||
const node = this._current;
|
||||
if (node[$isCDATAXml]() && typeof node[$content] === "string") {
|
||||
const parser = new XFAParser();
|
||||
const root = parser.parse(node[$content]);
|
||||
node[$content] = null;
|
||||
node[$onChild](root);
|
||||
}
|
||||
|
||||
node[$finalize]();
|
||||
this._current = this._stack.pop();
|
||||
if (this._current[$onChild](node)) {
|
||||
|
|
|
@ -29,6 +29,7 @@ import {
|
|||
$hasItem,
|
||||
$hasSettableValue,
|
||||
$ids,
|
||||
$isCDATAXml,
|
||||
$isTransparent,
|
||||
$namespaceId,
|
||||
$nodeName,
|
||||
|
@ -1746,6 +1747,10 @@ class ExData extends ContentObject {
|
|||
this.usehref = attributes.usehref || "";
|
||||
}
|
||||
|
||||
[$isCDATAXml]() {
|
||||
return this.contentType === "text/html";
|
||||
}
|
||||
|
||||
[$onChild](child) {
|
||||
if (
|
||||
this.contentType === "text/html" &&
|
||||
|
|
|
@ -51,6 +51,7 @@ const $hasSettableValue = Symbol();
|
|||
const $ids = Symbol();
|
||||
const $indexOf = Symbol();
|
||||
const $insertAt = Symbol();
|
||||
const $isCDATAXml = Symbol();
|
||||
const $isDataValue = Symbol();
|
||||
const $isDescendent = Symbol();
|
||||
const $isTransparent = Symbol();
|
||||
|
@ -148,6 +149,10 @@ class XFAObject {
|
|||
return false;
|
||||
}
|
||||
|
||||
[$isCDATAXml]() {
|
||||
return false;
|
||||
}
|
||||
|
||||
[$setId](ids) {
|
||||
if (this.id && this[$namespaceId] === NamespaceIds.template.id) {
|
||||
ids.set(this.id, this);
|
||||
|
@ -970,6 +975,7 @@ export {
|
|||
$ids,
|
||||
$indexOf,
|
||||
$insertAt,
|
||||
$isCDATAXml,
|
||||
$isDataValue,
|
||||
$isDescendent,
|
||||
$isTransparent,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue