xml-crypto
Advanced tools
Comparing version 1.1.1 to 1.1.2
@@ -0,0 +0,0 @@ var select = require('xml-crypto').xpath |
@@ -0,0 +0,0 @@ var select = require('xpath').select |
@@ -0,0 +0,0 @@ /* jshint laxcomma: true */ |
@@ -0,0 +0,0 @@ var xpath = require('xpath'); |
@@ -81,10 +81,3 @@ /* jshint laxcomma: true */ | ||
*/ | ||
ExclusiveCanonicalization.prototype.renderNs = function(node, | ||
prefixesInScope, | ||
defaultNs, | ||
defaultNsForPrefix, | ||
inclusiveNamespacesPrefixList, | ||
ancestorNamespaces, | ||
topNode | ||
) { | ||
ExclusiveCanonicalization.prototype.renderNs = function(node, prefixesInScope, defaultNs, defaultNsForPrefix, inclusiveNamespacesPrefixList) { | ||
var a, i, p, attr | ||
@@ -95,2 +88,3 @@ , res = [] | ||
, currNs = node.namespaceURI || ""; | ||
//handle the namespaceof the node itself | ||
@@ -109,15 +103,2 @@ if (node.prefix) { | ||
if(topNode) { | ||
for(var j = 0; j < ancestorNamespaces.length; j++) { | ||
var ancestorNs = ancestorNamespaces[j]; | ||
for(var k = 0; k < inclusiveNamespacesPrefixList.length; k++) { | ||
var inclusiveNs = inclusiveNamespacesPrefixList[k]; | ||
if(ancestorNs.prefix === inclusiveNs && !isPrefixInScope(prefixesInScope, ancestorNs.prefix, ancestorNs.namespaceURI)) { | ||
nsListToRender.push({"prefix": ancestorNs.prefix, "namespaceURI": ancestorNs.namespaceURI}); | ||
prefixesInScope.push({"prefix": ancestorNs.prefix, "namespaceURI": ancestorNs.namespaceURI}); | ||
} | ||
} | ||
} | ||
} | ||
//handle the attributes namespace | ||
@@ -128,8 +109,5 @@ if (node.attributes) { | ||
//handle all prefixed attributes that are included in the prefix list and where | ||
//the prefix is not defined already | ||
if (attr.prefix && | ||
!isPrefixInScope(prefixesInScope, attr.localName, attr.value) && | ||
(inclusiveNamespacesPrefixList.indexOf(attr.localName) >= 0)) { | ||
if (attr.prefix && !isPrefixInScope(prefixesInScope, attr.localName, attr.value) && inclusiveNamespacesPrefixList.indexOf(attr.localName) >= 0) { | ||
nsListToRender.push({"prefix": attr.localName, "namespaceURI": attr.value}); | ||
@@ -141,23 +119,5 @@ prefixesInScope.push({"prefix": attr.localName, "namespaceURI": attr.value}); | ||
//the prefix is not defined already | ||
if (attr.prefix && attr.prefix!=="xmlns" && attr.prefix!=="xml") { | ||
var artificiallyIntroduced = false; | ||
if(attr.namespaceURI === undefined) { | ||
//This could mean that the namespace Uri has been reset to "", or it could mean we have artificially | ||
//introduced it because it was in inclusiveNamespacePrefixList | ||
if(inclusiveNamespacesPrefixList.indexOf(attr.prefix) >= 0) { | ||
for(var j = 0; j < ancestorNamespaces.length; j++) { | ||
var ancestorNs = ancestorNamespaces[j]; | ||
if(ancestorNs.prefix === attr.prefix) { | ||
artificiallyIntroduced = true; | ||
break; | ||
} | ||
} | ||
} | ||
} | ||
if(!artificiallyIntroduced) { | ||
if(!isPrefixInScope(prefixesInScope, attr.prefix, attr.namespaceURI)) { | ||
nsListToRender.push({"prefix": attr.prefix, "namespaceURI": attr.namespaceURI|| defaultNsForPrefix[attr.prefix]}); | ||
prefixesInScope.push({"prefix": attr.prefix, "namespaceURI": attr.namespaceURI|| defaultNsForPrefix[attr.prefix]}); | ||
} | ||
} | ||
if (attr.prefix && !isPrefixInScope(prefixesInScope, attr.prefix, attr.namespaceURI) && attr.prefix!="xmlns" && attr.prefix!="xml") { | ||
nsListToRender.push({"prefix": attr.prefix, "namespaceURI": attr.namespaceURI}); | ||
prefixesInScope.push({"prefix": attr.prefix, "namespaceURI": attr.namespaceURI}); | ||
} | ||
@@ -180,9 +140,4 @@ } | ||
ExclusiveCanonicalization.prototype.processInner = function(node, | ||
prefixesInScope, | ||
defaultNs, | ||
defaultNsForPrefix, | ||
inclusiveNamespacesPrefixList, | ||
ancestorNamespaces, | ||
topNode) { | ||
ExclusiveCanonicalization.prototype.processInner = function(node, prefixesInScope, defaultNs, defaultNsForPrefix, inclusiveNamespacesPrefixList) { | ||
if (node.nodeType === 8) { return this.renderComment(node); } | ||
@@ -192,3 +147,3 @@ if (node.data) { return utils.encodeSpecialCharactersInText(node.data); } | ||
var i, pfxCopy | ||
, ns = this.renderNs(node, prefixesInScope, defaultNs, defaultNsForPrefix, inclusiveNamespacesPrefixList, ancestorNamespaces, topNode) | ||
, ns = this.renderNs(node, prefixesInScope, defaultNs, defaultNsForPrefix, inclusiveNamespacesPrefixList) | ||
, res = ["<", node.tagName, ns.rendered, this.renderAttrs(node, ns.newDefaultNs), ">"]; | ||
@@ -198,3 +153,3 @@ | ||
pfxCopy = prefixesInScope.slice(0); | ||
res.push(this.processInner(node.childNodes[i], pfxCopy, ns.newDefaultNs, defaultNsForPrefix, inclusiveNamespacesPrefixList, ancestorNamespaces, false)); | ||
res.push(this.processInner(node.childNodes[i], pfxCopy, ns.newDefaultNs, defaultNsForPrefix, inclusiveNamespacesPrefixList)); | ||
} | ||
@@ -253,6 +208,5 @@ | ||
var defaultNsForPrefix = options.defaultNsForPrefix || {}; | ||
var ancestorNamespaces = options.ancestorNamespaces || []; | ||
if (!(inclusiveNamespacesPrefixList instanceof Array)) { inclusiveNamespacesPrefixList = inclusiveNamespacesPrefixList.split(' '); } | ||
var res = this.processInner(node, [], defaultNs, defaultNsForPrefix, inclusiveNamespacesPrefixList, ancestorNamespaces, true); | ||
var res = this.processInner(node, [], defaultNs, defaultNsForPrefix, inclusiveNamespacesPrefixList); | ||
return res; | ||
@@ -259,0 +213,0 @@ }; |
@@ -376,5 +376,5 @@ var xpath = require('xpath') | ||
ancestorNamespaces = findAncestorNs(doc, "//*[local-name()='SignedInfo']"); | ||
} | ||
ancestorNamespaces = findAncestorNs(doc, "//*[local-name()='SignedInfo']"); | ||
var c14nOptions = { | ||
@@ -453,8 +453,21 @@ ancestorNamespaces: ancestorNamespaces | ||
/** | ||
* Search for ancestor namespaces before validating references. Ancestor namespaces are needed | ||
* even for exclusive canonicalization because they may be needed for namespaces that are on the | ||
* inclusive namespace prefix list. | ||
* When canonicalization algorithm is non-exclusive, search for ancestor namespaces | ||
* before validating references. | ||
*/ | ||
if(Array.isArray(ref.transforms)){ | ||
ref.ancestorNamespaces = findAncestorNs(doc, elemXpath); | ||
var hasNonExcC14nTransform = false; | ||
for(var t in ref.transforms){ | ||
if(!ref.transforms.hasOwnProperty(t)) continue; | ||
if(ref.transforms[t] === "http://www.w3.org/TR/2001/REC-xml-c14n-20010315" | ||
|| ref.transforms[t] === "http://www.w3.org/TR/2001/REC-xml-c14n-20010315#WithComments") | ||
{ | ||
hasNonExcC14nTransform = true; | ||
break; | ||
} | ||
} | ||
if(hasNonExcC14nTransform){ | ||
ref.ancestorNamespaces = findAncestorNs(doc, elemXpath); | ||
} | ||
} | ||
@@ -461,0 +474,0 @@ |
@@ -0,0 +0,0 @@ var select = require('xpath').select |
{ | ||
"name": "xml-crypto", | ||
"version": "1.1.1", | ||
"version": "1.1.2", | ||
"description": "Xml digital signature and encryption library for Node.js", | ||
@@ -5,0 +5,0 @@ "engines": { |
@@ -182,3 +182,4 @@ ## xml-crypto | ||
See [xpath](https://github.com/goto100/xpath) for usage | ||
See [xpath.js](https://github.com/yaronn/xpath.js) for usage. Note that this is actually using | ||
[another library](https://github.com/goto100/xpath) as the underlying implementation. | ||
@@ -185,0 +186,0 @@ ### SignedXml |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
72816
455
1246