Repository navigation
Conversation
When the node-set was on the right side, the operands were swapped without flipping the operator, so 10 > @price was evaluated as @price > 10. A boolean was compared with each node instead of with boolean(node-set), so //missing = false() was false. A string that looked like a number was compared as a number, so @n = '1.0' matched n="1".
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Comparisons between a node-set and another value give wrong results in three cases:
/root/item[10 > @price]overprice="5",price="50"5055150 > /root/childover200,300truefalsefalse'150' > /root/childover200,300truefalsefalse/root/missing = false()falsetruetruefalse() < /root/child(non-empty)falsetruetrue/root/child = '100.0'over100truefalsefalseCause:
10 > @pricewas evaluated as@price > 10.//missing = false()wasfalse.=/!=, so@n = '1.0'matchedn="1".https://www.w3.org/TR/xpath-10/#booleans
Now the node value is always put on the node-set's side, a boolean is compared with
boolean(node-set), and a string is compared as a string. The existingcomparealready turns strings into numbers for<,<=,>,>=, so'199' < /root/childstill compares numbers.The six new tests fail on master and pass here.
bundle exec rake testpasses (847 tests). I also ran ~2,300 XPath expressions against libxml2 through lxml: every result this PR changes now matches libxml2, and nothing else changed. The only comparison differences left are nodes like<v>1e2</v>, which libxml2 reads as 100 but XPath 1.0'snumber()reads as NaN.