Skip to content

Commit f7f887a

Browse files
committed
fix: explicitly check for attributes with no namespace when namespaceUri is undefined
1 parent e2f72ee commit f7f887a

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/signed-xml.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -565,13 +565,20 @@ export class SignedXml {
565565
for (const idAttr of this.idAttributes) {
566566
if (typeof idAttr === "string") {
567567
if (uri === elem.getAttribute(idAttr)) {
568+
// We look for attributes in any namespace or no namespace
568569
ref.xpath = `//*[@*[local-name(.)='${idAttr}']='${uri}']`;
569570
break; // found the correct element, no need to check further
570571
}
571572
} else {
572573
const attr = utils.findAttr(elem, idAttr.localName, idAttr.namespaceUri);
573574
if (attr && uri === attr.value) {
574-
ref.xpath = `//*[@*[local-name(.)='${idAttr.localName}' and namespace-uri(.)='${idAttr.namespaceUri}']='${uri}']`;
575+
if (idAttr.namespaceUri !== undefined) {
576+
// When namespaceUri is set, we look for attributes in that specific namespace
577+
ref.xpath = `//*[@*[local-name(.)='${idAttr.localName}' and namespace-uri(.)='${idAttr.namespaceUri}']='${uri}']`;
578+
} else {
579+
// When namespaceUri is explicitly set to undefined, we look only for attributes without a namespace
580+
ref.xpath = `//*[@*[local-name(.)='${idAttr.localName}' and namespace-uri(.)='']='${uri}']`;
581+
}
575582
break; // found the correct element, no need to check further
576583
}
577584
}

0 commit comments

Comments
 (0)