xml-crypto
Advanced tools
Comparing version
@@ -10,15 +10,20 @@ /* jshint laxcomma: true */ | ||
ExclusiveCanonicalization.prototype.attrCompare = function(a,b) { | ||
if (!a.prefix && b.prefix) return -1; | ||
if (!b.prefix && a.prefix) return 1; | ||
return a.name.localeCompare(b.name); | ||
if (!a.namespaceURI && b.namespaceURI) return -1; | ||
if (!b.namespaceURI && a.namespaceURI) return 1; | ||
var left = a.namespaceURI + a.localName | ||
var right = b.namespaceURI + b.localName | ||
var res = left.localeCompare(right); | ||
return res; | ||
}; | ||
ExclusiveCanonicalization.prototype.nsCompare = function(a,b) { | ||
var attr1 = a.prefix+a.namespaceURI; | ||
var attr2 = b.prefix+b.namespaceURI; | ||
var attr1 = a.prefix//+a.namespaceURI; | ||
var attr2 = b.prefix//+b.namespaceURI; | ||
if (attr1 == attr2) return 0; | ||
return attr1.localeCompare(attr2); | ||
return attr1.localeCompare(attr2); | ||
}; | ||
ExclusiveCanonicalization.prototype.renderAttrs = function(node) { | ||
ExclusiveCanonicalization.prototype.renderAttrs = function(node, defaultNS) { | ||
var a, i, attr | ||
@@ -32,3 +37,4 @@ , res = [] | ||
//ignore namespace definition attributes | ||
if (attr.name.indexOf("xmlns") === 0) continue; | ||
if (attr.name.indexOf("xmlns") === 0) continue; | ||
if (!attr.namespaceURI && defaultNS) attr.namespaceURI = defaultNS; | ||
attrListToRender.push(attr); | ||
@@ -116,3 +122,3 @@ } | ||
, ns = this.renderNs(node, prefixesInScope, defaultNs, inclusiveNamespacesPrefixList) | ||
, res = ["<", node.tagName, ns.rendered, this.renderAttrs(node), ">"]; | ||
, res = ["<", node.tagName, ns.rendered, this.renderAttrs(node, ns.newDefaultNs), ">"]; | ||
@@ -119,0 +125,0 @@ for (i = 0; i < node.childNodes.length; ++i) { |
{ | ||
"name": "xml-crypto", | ||
"version": "0.0.23", | ||
"version": "0.1.24", | ||
"description": "Xml digital signature and encryption library for Node.js", | ||
@@ -5,0 +5,0 @@ "engines": { "node": ">=0.4.0" }, |
@@ -84,3 +84,3 @@ var ExclusiveCanonicalization = require("../lib/exclusive-canonicalization").ExclusiveCanonicalization | ||
"//*[local-name(.)='child']", | ||
"<p:child xmlns:inclusive2=\"ns3\" xmlns:inclusive=\"ns2\" xmlns:p=\"ns\"><inclusive:inner>123</inclusive:inner><inclusive2:inner>456</inclusive2:inner></p:child>", | ||
"<p:child xmlns:inclusive=\"ns2\" xmlns:inclusive2=\"ns3\" xmlns:p=\"ns\"><inclusive:inner>123</inclusive:inner><inclusive2:inner>456</inclusive2:inner></p:child>", | ||
"inclusive inclusive2") | ||
@@ -346,2 +346,21 @@ }, | ||
}, | ||
"The XML canonicalization method processes a node-set by imposing the following additional document order rules on the namespace and attribute nodes of each element: \ | ||
- An element's namespace and attribute nodes have a document order position greater than the element but less than any child node of the element. \ | ||
Namespace nodes have a lesser document order position than attribute nodes. \ | ||
- An element's namespace nodes are sorted lexicographically by local name (the default namespace node, if one exists, has no local name and is therefore lexicographically least). \ | ||
- An element's attribute nodes are sorted lexicographically with namespace URI as the primary key and local name as the secondary key (an empty namespace URI is lexicographically least). \ | ||
Lexicographic comparison, which orders strings from least to greatest alphabetically, is based on the UCS codepoint values, which is equivalent to lexicographic ordering based on UTF-8.": function (test) { | ||
compare(test, | ||
'<root xmlns:b="moo" b:attr1="a1" a:attr1="a1" b:attr4="b4" xmlns="foo" b:attr3="a3" xmlns:a="zoo"></root>', | ||
"//*[local-name(.)='root']", | ||
'<root xmlns="foo" xmlns:a="zoo" xmlns:b="moo" b:attr1="a1" b:attr3="a3" b:attr4="b4" a:attr1="a1"></root>') | ||
}, | ||
"saml attributed order (bug #25)": function (test) { | ||
compare(test, | ||
'<root xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol" xmlns="urn:oasis:names:tc:SAML:2.0:protocol" xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion" samlp:a="1" saml:a="1"></root>', | ||
"//*[local-name(.)='root']", | ||
'<root xmlns="urn:oasis:names:tc:SAML:2.0:protocol" xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion" xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol" saml:a="1" samlp:a="1"></root>') | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
246055
0.84%1500
1.42%