Skip to content

Commit

Permalink
Fixed: [Xpath API do not support filter data by wildcard](#313)
Browse files Browse the repository at this point in the history
  • Loading branch information
olofhagsand committed Mar 15, 2022
1 parent 159ac0a commit a973eaa
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions lib/src/clixon_xpath.c
Original file line number Diff line number Diff line change
Expand Up @@ -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){
Expand Down
4 changes: 4 additions & 0 deletions test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
30 changes: 30 additions & 0 deletions test/test_xpath.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 <<EOF > $xml
<aaa>
Expand Down Expand Up @@ -75,6 +76,26 @@ cat <<EOF > $xml3
</bbb>
EOF

# Asterisk
cat <<EOF > $xml4
<root>
<x>
<a>111</a>
</x>
<y>
<a>222</a>
</y>
<z>
<b>111</b>
</z>
<w>
<a>111</a>
</w>
</root>
EOF



new "xpath /"
expecteof "$clixon_util_xpath -f $xml -p /" 0 "" "^nodeset:0:<aaa><bbb x=\"hello\"><ccc>42</ccc></bbb><bbb x=\"bye\"><ccc>99</ccc></bbb><ddd><ccc>22</ccc></ddd></aaa>$"

Expand Down Expand Up @@ -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:<a>111</a>1:<a>222</a>2:<a>111</a>"

new "xpath /root/*/b"
expecteof "$clixon_util_xpath -f $xml4 -p /root/*/b" 0 "" "nodeset:0:<b>111</b>"

new "xpath /root/*/*[.='111']"
expecteof "$clixon_util_xpath -f $xml4 -p /root/*/*[.='111']" 0 "" "nodeset:0:<a>111</a>1:<b>111</b>2:<a>111</a>"

rm -rf $dir

# unset conditional parameters
Expand Down

0 comments on commit a973eaa

Please sign in to comment.