Skip to content

Commit 57e257f

Browse files
committed
apply a workaround for xml xpath != bug
1 parent 7523915 commit 57e257f

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

test/signature_test.dart

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -819,8 +819,11 @@ void verifyAddsId(String mode, String nsMode) {
819819
final signedXml = sig.originalXmlWithIds;
820820
final doc = parseFromString(signedXml);
821821

822-
final op = nsMode == 'equal' ? '=' : '!=';
823-
final xpath = "//*[local-name()='{elem}' and '_{id}' = @*[local-name()='Id' and namespace-uri()$op'$wsSecurityUtilityNamespace']]";
822+
// xml 7.0.1 mis-evaluates string `!=` in this predicate shape, so keep the
823+
// old `namespace-uri()='...'` case and express the non-equal case as `not(...)`.
824+
final xpath = nsMode == 'equal'
825+
? "//*[local-name()='{elem}' and '_{id}' = @*[local-name()='Id' and namespace-uri()='$wsSecurityUtilityNamespace']]"
826+
: "//*[local-name()='{elem}' and '_{id}' = @*[local-name()='Id' and not(namespace-uri()='$wsSecurityUtilityNamespace')]]";
824827

825828
//verify each of the signed nodes now has an "Id" attribute with the right value
826829
nodeExists(doc, xpath.replaceFirst('{id}', '0').replaceFirst('{elem}', 'x'));

0 commit comments

Comments
 (0)