File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -178,7 +178,7 @@ def predicate_to_string( path, &block )
178
178
when :literal
179
179
path . shift
180
180
string << " "
181
- string << path . shift . inspect
181
+ string << quote_literal ( path . shift )
182
182
string << " "
183
183
else
184
184
string << " "
@@ -189,6 +189,21 @@ def predicate_to_string( path, &block )
189
189
end
190
190
191
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
+ else
203
+ literal . inspect
204
+ end
205
+ end
206
+
192
207
#LocationPath
193
208
# | RelativeLocationPath
194
209
# | '/' RelativeLocationPath?
You can’t perform that action at this time.
0 commit comments