You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
XPath: and/or/div/mod right after a predicate raise ParseException #384
A word operator (and, or, div, mod) right after a predicate fails to parse:
require"rexml/document"doc=REXML::Document.new("<r><v>6</v><v>2</v></r>")REXML::XPath.match(doc,"//v[1] and true()")# REXML::ParseException: Garbage component exists at the end: <and true()>: <//v[1] and true()>REXML::XPath.match(doc,"/r/v[1] div 3")# REXML::ParseException: Garbage component exists at the end: <div 3>: </r/v[1] div 3>
Expected [true] and [2.0] (libxml2 gives those). Symbol operators work (//v[1] * 3, //v[1] = 6), and so do (//v[1]) div 3 and //v div 3.
Cause: Predicate in lib/rexml/parsers/xpathparser.rb calls path.lstrip after each ], so it returns "and true()". OrExpr, AndExpr and MultiplicativeExpr then look for /^\s*( and )/, /^\s*( or )/ and /^\s*(\*| div | mod )\s*/, which need the space before the word, so they don't match.
Possible fix: in Predicate, only strip the whitespace when another [ follows, and otherwise return the path with its leading space.
Activity