diff --git a/CHANGELOG.md b/CHANGELOG.md index 17310a1c..bb3489ea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -39,6 +39,7 @@ Expected: May 2022 ### Corrected Bugs +* Fixed: [Xpath API do not support filter data by wildcard](https://github.com/clicon/clixon/issues/313) * Fixed: SEGV in cli show yang ## 5.6.0 diff --git a/lib/src/clixon_xpath.c b/lib/src/clixon_xpath.c index a7aeecf7..3ba95a39 100644 --- a/lib/src/clixon_xpath.c +++ b/lib/src/clixon_xpath.c @@ -962,6 +962,9 @@ traverse_canonical(xpath_tree *xs, switch (xs->xs_type){ case XP_NODE: /* s0 is namespace prefix, s1 is name */ + /* Nodetest = * needs no prefix */ + if (xs->xs_s1 && strcmp(xs->xs_s1, "*") == 0) + break; prefix0 = xs->xs_s0; if ((namespace = xml_nsctx_get(nsc0, prefix0)) == NULL){ if ((cb = cbuf_new()) == NULL){ diff --git a/test/README.md b/test/README.md index b8a1f96b..fac5c5e6 100644 --- a/test/README.md +++ b/test/README.md @@ -134,3 +134,7 @@ If you do not have them, generate self-signed certs, eg as follows: ``` There are also client-cert tests, eg `test_ssl_certs.sh` + +## Known issues + +[Workaround: Unicode double-quote in iana-if-type@2022-03-07.yang](https://github.com/clicon/clixon/issues/315) diff --git a/test/test_xpath.sh b/test/test_xpath.sh index 479666ec..29432cce 100755 --- a/test/test_xpath.sh +++ b/test/test_xpath.sh @@ -10,6 +10,7 @@ s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi xml=$dir/xml.xml xml2=$dir/xml2.xml xml3=$dir/xml3.xml +xml4=$dir/xml4.xml cat < $xml @@ -75,6 +76,26 @@ cat < $xml3 EOF +# Asterisk +cat < $xml4 + + + 111 + + + 222 + + + 111 + + + 111 + + +EOF + + + new "xpath /" expecteof "$clixon_util_xpath -f $xml -p /" 0 "" "^nodeset:0:429922$" @@ -234,6 +255,15 @@ expectpart "$($clixon_util_xpath -f $xml3 -l o -p "dontexist()")" 255 "Unknown x new "xpath enum-value nyi" expectpart "$($clixon_util_xpath -f $xml3 -l o -p "enum-value()")" 255 "XPATH function \"enum-value\" is not implemented" +new "xpath /root/*/a" +expecteof "$clixon_util_xpath -f $xml4 -p /root/*/a" 0 "" "nodeset:0:1111:2222:111" + +new "xpath /root/*/b" +expecteof "$clixon_util_xpath -f $xml4 -p /root/*/b" 0 "" "nodeset:0:111" + +new "xpath /root/*/*[.='111']" +expecteof "$clixon_util_xpath -f $xml4 -p /root/*/*[.='111']" 0 "" "nodeset:0:1111:1112:111" + rm -rf $dir # unset conditional parameters