Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
xpath abbreviate: add support for string literal that contains double…
…-quote (#96) This adds support for a string literal that contains a double-quote to `XPathParser#abbreviate`. Basically any literal that contains a double-quote `"` must be quoted by single-quotes `'` since XPath 1.0 does not support any escape characters. The change improves the following test script ```ruby require 'rexml' parsed = REXML::Parsers::XPathParser.new.parse('/a[b/text()=concat("c\'",\'"d\')]') puts "#{parsed}" puts "" appreviated = REXML::Parsers::XPathParser.new.abbreviate parsed puts "#{appreviated}" ``` ### Output Before Change ``` [:document, :child, :qname, "", "a", :predicate, [:eq, [:child, :qname, "", "b", :child, :text], [:function, "concat", [[:literal, "c'"], [:literal, "\"d"]]]]] /a[ b/text() = concat( "c'" , "\"d" ) ] ``` ### Output After Change ``` [:document, :child, :qname, "", "a", :predicate, [:eq, [:child, :qname, "", "b", :child, :text], [:function, "concat", [[:literal, "c'"], [:literal, "\"d"]]]]] /a[ b/text() = concat( "c'" , '"d' ) ] ``` --------- Co-authored-by: Matt Pulver <pulver@users.noreply.github.com>
- Loading branch information