Skip to content

Commit 9e1c6ea

Browse files
committed
aFix logic for multiple PrefixList + fix some old whitespace issues
1 parent 1632e71 commit 9e1c6ea

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

lib/signed-xml.js

+13-10
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ function FileKeyInfo(file) {
1818
this.file = file
1919

2020
this.getKeyInfo = function(key, prefix) {
21-
prefix = prefix || ''
22-
prefix = prefix ? prefix + ':' : prefix
21+
prefix = prefix || ''
22+
prefix = prefix ? prefix + ':' : prefix
2323
return "<" + prefix + "X509Data></" + prefix + "X509Data>"
2424
}
2525

@@ -450,16 +450,15 @@ SignedXml.prototype.validateReferences = function(doc) {
450450
/**
451451
* Search for ancestor namespaces before validating references.
452452
*/
453-
if(Array.isArray(ref.transforms)){
454-
455-
ref.ancestorNamespaces = findAncestorNs(doc, elemXpath);
453+
if(Array.isArray(ref.transforms)){
454+
ref.ancestorNamespaces = findAncestorNs(doc, elemXpath);
456455
}
457456

458457
var c14nOptions = {
459458
inclusiveNamespacesPrefixList: ref.inclusiveNamespacesPrefixList,
460459
ancestorNamespaces: ref.ancestorNamespaces
461460
};
462-
461+
463462
var canonXml = this.getCanonXml(ref.transforms, elem[0], c14nOptions);
464463

465464
var hash = this.findHashAlgorithm(ref.digestAlgorithm)
@@ -578,7 +577,11 @@ SignedXml.prototype.loadReference = function(ref) {
578577
if (inclusiveNamespaces.length > 0) {
579578
//Should really only be one prefix list, but maybe there's some circumstances where more than one to lets handle it
580579
for (var i = 0; i<inclusiveNamespaces.length; i++) {
581-
inclusiveNamespacesPrefixList = inclusiveNamespaces[i].getAttribute('PrefixList');
580+
if (inclusiveNamespacesPrefixList) {
581+
inclusiveNamespacesPrefixList = inclusiveNamespacesPrefixList + " " + inclusiveNamespaces[i].getAttribute('PrefixList');
582+
} else {
583+
inclusiveNamespacesPrefixList = inclusiveNamespaces[i].getAttribute('PrefixList');
584+
}
582585
}
583586
}
584587
}
@@ -881,10 +884,10 @@ SignedXml.prototype.createSignature = function(signedInfo, prefix) {
881884
var xmlNsAttr = 'xmlns'
882885

883886
if (prefix) {
884-
xmlNsAttr += ':' + prefix;
885-
prefix += ':';
887+
xmlNsAttr += ':' + prefix;
888+
prefix += ':';
886889
} else {
887-
prefix = '';
890+
prefix = '';
888891
}
889892

890893
//the canonicalization requires to get a valid xml node.

0 commit comments

Comments
 (0)