We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 54b7109 commit e08c52fCopy full SHA for e08c52f
lib/rexml/parsers/xpathparser.rb
@@ -178,7 +178,7 @@ def predicate_to_string( path, &block )
178
when :literal
179
path.shift
180
string << " "
181
- string << path.shift.inspect
+ string << quote_literal(path.shift)
182
183
else
184
@@ -189,6 +189,21 @@ def predicate_to_string( path, &block )
189
end
190
191
private
192
+ def quote_literal( literal )
193
+ case literal
194
+ when String
195
+ # XPath 1.0 does not support escape characters.
196
+ # Assumes literal does not contain both single and double quotes.
197
+ if literal.include?("'")
198
+ "\"#{literal}\""
199
+ else
200
+ "'#{literal}'"
201
+ end
202
203
+ literal.inspect
204
205
206
+
207
#LocationPath
208
# | RelativeLocationPath
209
# | '/' RelativeLocationPath?
0 commit comments