Properly handle backslash escaping

This commit is contained in:
Loic Nageleisen 2017-11-23 16:33:01 +01:00
parent a0f1153407
commit 86ce2b65ff
2 changed files with 25 additions and 11 deletions

View file

@ -292,7 +292,10 @@ module Rebel
end
def escape_str(str)
str.gsub(@string_quote, @escaped_string_quote)
str.dup.tap do |s|
s.gsub!('\\') { @escaped_string_backslash } if @escaped_string_backslash
s.gsub!(@string_quote) { @escaped_string_quote }
end
end
def value(v)
@ -390,6 +393,7 @@ module Rebel
@identifier_quote = options[:identifier_quote] || '"'
@string_quote = options[:string_quote] || "'"
@escaped_string_quote = options[:escaped_string_quote] || "''"
@escaped_string_backslash = options[:escaped_string_backslash]
@true_literal = options[:true_literal] || 'TRUE'
@false_literal = options[:false_literal] || 'FALSE'