diff --git a/src/core/xfa/builder.js b/src/core/xfa/builder.js index d010b2052..19bd1f21b 100644 --- a/src/core/xfa/builder.js +++ b/src/core/xfa/builder.js @@ -18,6 +18,7 @@ import { $cleanup, $finalize, $ids, + $isNsAgnostic, $nsAttributes, $onChild, $resolvePrototypes, @@ -67,6 +68,7 @@ class Empty extends XFAObject { class Builder { constructor() { this._namespaceStack = []; + this._nsAgnosticLevel = 0; // Each prefix has its own stack this._namespacePrefixes = new Map(); @@ -118,18 +120,27 @@ class Builder { (namespaceToUse && namespaceToUse[$buildXFAObject](name, attributes)) || new Empty(); + if (node[$isNsAgnostic]()) { + this._nsAgnosticLevel++; + } + // In case the node has some namespace things, // we must pop the different stacks. - if (hasNamespaceDef || prefixes) { + if (hasNamespaceDef || prefixes || node[$isNsAgnostic]()) { node[$cleanup] = { hasNamespace: hasNamespaceDef, prefixes, + nsAgnostic: node[$isNsAgnostic](), }; } return node; } + isNsAgnostic() { + return this._nsAgnosticLevel > 0; + } + _searchNamespace(nsName) { let ns = this._namespaces.get(nsName); if (ns) { @@ -178,7 +189,7 @@ class Builder { } clean(data) { - const { hasNamespace, prefixes } = data; + const { hasNamespace, prefixes, nsAgnostic } = data; if (hasNamespace) { this._currentNamespace = this._namespaceStack.pop(); } @@ -187,6 +198,9 @@ class Builder { this._namespacePrefixes.get(prefix).pop(); }); } + if (nsAgnostic) { + this._nsAgnosticLevel--; + } } } diff --git a/src/core/xfa/datasets.js b/src/core/xfa/datasets.js index 911a87741..aed3e2f6e 100644 --- a/src/core/xfa/datasets.js +++ b/src/core/xfa/datasets.js @@ -15,6 +15,7 @@ import { $appendChild, + $isNsAgnostic, $namespaceId, $nodeName, $onChild, @@ -29,6 +30,10 @@ class Data extends XmlObject { constructor(attributes) { super(DATASETS_NS_ID, "data", attributes); } + + [$isNsAgnostic]() { + return true; + } } class Datasets extends XFAObject { diff --git a/src/core/xfa/parser.js b/src/core/xfa/parser.js index d29cce501..19a197772 100644 --- a/src/core/xfa/parser.js +++ b/src/core/xfa/parser.js @@ -118,12 +118,12 @@ class XFAParser extends XMLParserBase { return [namespace, prefixes, attributeObj]; } - _getNameAndPrefix(name) { + _getNameAndPrefix(name, nsAgnostic) { const i = name.indexOf(":"); if (i === -1) { return [name, null]; } - return [name.substring(i + 1), name.substring(0, i)]; + return [name.substring(i + 1), nsAgnostic ? "" : name.substring(0, i)]; } onBeginElement(tagName, attributes, isEmpty) { @@ -131,7 +131,10 @@ class XFAParser extends XMLParserBase { attributes, tagName ); - const [name, nsPrefix] = this._getNameAndPrefix(tagName); + const [name, nsPrefix] = this._getNameAndPrefix( + tagName, + this._builder.isNsAgnostic() + ); const node = this._builder.build({ nsPrefix, name, diff --git a/src/core/xfa/xfa_object.js b/src/core/xfa/xfa_object.js index 8e55e20c9..a2444a522 100644 --- a/src/core/xfa/xfa_object.js +++ b/src/core/xfa/xfa_object.js @@ -60,6 +60,7 @@ const $isCDATAXml = Symbol(); const $isBindable = Symbol(); const $isDataValue = Symbol(); const $isDescendent = Symbol(); +const $isNsAgnostic = Symbol(); const $isSplittable = Symbol(); const $isThereMoreWidth = Symbol(); const $isTransparent = Symbol(); @@ -160,6 +161,10 @@ class XFAObject { ); } + [$isNsAgnostic]() { + return false; + } + [$acceptWhitespace]() { return false; } @@ -1087,6 +1092,7 @@ export { $isCDATAXml, $isDataValue, $isDescendent, + $isNsAgnostic, $isSplittable, $isThereMoreWidth, $isTransparent, diff --git a/test/pdfs/xfa_bug1721600.pdf.link b/test/pdfs/xfa_bug1721600.pdf.link new file mode 100644 index 000000000..461e891cf --- /dev/null +++ b/test/pdfs/xfa_bug1721600.pdf.link @@ -0,0 +1 @@ +https://bugzilla.mozilla.org/attachment.cgi?id=9232367 diff --git a/test/test_manifest.json b/test/test_manifest.json index 5ff77b568..522b6a12f 100644 --- a/test/test_manifest.json +++ b/test/test_manifest.json @@ -952,6 +952,15 @@ "enableXfa": true, "type": "eq" }, + { "id": "xfa_bug1721600", + "file": "pdfs/xfa_bug1721600.pdf", + "md5": "5f514f476169eeb7254da380a8db495a", + "link": true, + "rounds": 1, + "lastPage": 1, + "enableXfa": true, + "type": "eq" + }, { "id": "xfa_bug1720182", "file": "pdfs/xfa_bug1720182.pdf", "md5": "1351f816f0509fe750ca61ef2bd40872",