Skip to content

XPath Comparison Unexpected Error  #18

@mirko314

Description

@mirko314

Hi again,

There seems to be a bug regarding boolean comparisons in the XPath evaluation.

Executing false()>=false() throws a NoMethodError (undefined method '>=' for false:FalseClass) Error.
Expected result: true

This leads to more crashes e.g when comparing empty-node sets with a boolean:
The expression /nonexistent>=false() throws an error as well.

Executing false()=false() however leads to the correct result true.

Complete Error:

Testing library: rexml , xpath: false()>=false()
Traceback (most recent call last):
        10: from /app/libraries/rexml/rexml.rb:17:in `<main>'
         9: from /usr/local/rvm/gems/ruby-2.6.3/gems/rexml-3.2.1/lib/rexml/xpath.rb:78:in `match'
         8: from /usr/local/rvm/gems/ruby-2.6.3/gems/rexml-3.2.1/lib/rexml/xpath_parser.rb:70:in `parse'
         7: from /usr/local/rvm/gems/ruby-2.6.3/gems/rexml-3.2.1/lib/rexml/xpath_parser.rb:133:in `match'
         6: from /usr/local/rvm/gems/ruby-2.6.3/gems/rexml-3.2.1/lib/rexml/xpath_parser.rb:345:in `expr'
         5: from /usr/local/rvm/gems/ruby-2.6.3/gems/rexml-3.2.1/lib/rexml/xpath_parser.rb:811:in `equality_relational_compare'
         4: from /usr/local/rvm/gems/ruby-2.6.3/gems/rexml-3.2.1/lib/rexml/syncenumerator.rb:27:in `each'
         3: from /usr/local/rvm/gems/ruby-2.6.3/gems/rexml-3.2.1/lib/rexml/syncenumerator.rb:27:in `times'
         2: from /usr/local/rvm/gems/ruby-2.6.3/gems/rexml-3.2.1/lib/rexml/syncenumerator.rb:28:in `block in each'
         1: from /usr/local/rvm/gems/ruby-2.6.3/gems/rexml-3.2.1/lib/rexml/xpath_parser.rb:814:in `block in equality_relational_compare'
/usr/local/rvm/gems/ruby-2.6.3/gems/rexml-3.2.1/lib/rexml/xpath_parser.rb:893:in `compare': undefined method `>=' for false:FalseClass (NoMethodError)

Furthermore we found that executing number(false()) results in NaN which is incorrect. Instead zero should be returned.

I hope this helps and best regards,
Mirko

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions