Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions lib/rexml/parsers/xpathparser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -591,14 +591,15 @@ def PathExpr path, parsed
path = path.lstrip
n = []
rest = FilterExpr( path, n )
if rest != path
if rest == path
rest = LocationPath(rest, n)
else
Comment on lines +594 to +596
if rest and rest[0] == ?/
rest = RelativeLocationPath(rest, n)
parsed.concat(n)
return rest
end
end
rest = LocationPath(rest, n) if rest =~ /\A[\/\.\@\[\w*]/
parsed.concat(n)
rest
end
Expand Down
13 changes: 13 additions & 0 deletions test/parser/test_xpath.rb
Original file line number Diff line number Diff line change
Expand Up @@ -111,5 +111,18 @@ def test_filter_string_double_quote
abbreviate("a/b[attribute::name='double \" quote']/c"))
end
end

def test_mult_and_spaces
parser = REXML::Parsers::XPathParser.new
assert_equal(parser.parse("1 * 2 * 3"), parser.parse("1*2*3"))
assert_equal(parser.parse("a[( ( 1 + 2 ) * 3 + 4 * ( 5 + 6 ) ) * 7 < 8]"), parser.parse("a[((1+2)*3+4*(5+6))*7<8]"))
# number(a/b) * 2
assert_equal(parser.parse("(a/b) * 2"), parser.parse("(a/b)*2"))
assert_equal(parser.parse("a/b * 2"), parser.parse("a/b*2"))
# number(a/b/*) * 2
assert_equal(parser.parse("a/b/* * 2"), parser.parse("a/b/**2"))
# number(*) * number(*/*) * number(*)
assert_equal(parser.parse("* * */* * *"), parser.parse("***/***"))
end
end
end
Loading