Bug xpath() fails to handle node-set unions correctly which use the "|" operator

Ulti

Member
xpath() fails to handle node-set unions correctly which use the "|" operator

The mafia version I'm using is r15777.

Run this and you'll get an "invalid xpath expression ()" error:
Code:
ashq string[int] s=xpath(visit_url('questlog.php?which=7'),'//a[@href="campground.php"]/text() | //anhtmltagwhichwontexist/text()');print(count(s));foreach v in s{print(s[v]);}
Now run the same xpath expression on a different page:
Code:
ashq string[int] s=xpath(visit_url('charsheet.php'),'//a[@href="campground.php"]/text() | //anhtmltagwhichwontexist/text()');print(count(s));foreach v in s{print(s[v]);}
and it will print "0" correctly.

Now try running xpath on the first page again but swapping the order of the union:
Code:
ashq string[int] s=xpath(visit_url('questlog.php?which=7'),'//anhtmltagwhichwontexist/text() | //a[@href="campground.php"]/text()');print(count(s));foreach v in s{print(s[v]);}
and it mistakenly prints "0" when it should print "1".

Now try it without the union:
Code:
ashq string[int] s=xpath(visit_url('questlog.php?which=7'),'//a[@href="campground.php"]/text()');print(count(s));foreach v in s{print(s[v]);}
and it works beautifully printing "1" followed by "Back to your Campsite"
 
Top