[ruby/rexml] use #inspect to print meta-characters in error messages

a124a19b9a
This commit is contained in:
FUJI Goro (gfx) 2019-01-05 22:34:03 +09:00 committed by Hiroshi SHIBATA
parent 81354bbd1b
commit 982208c650

View file

@ -137,7 +137,7 @@ module REXML
case c.ord case c.ord
when *VALID_CHAR when *VALID_CHAR
else else
raise "Illegal character #{c.inspect} in raw string \"#{string}\"" raise "Illegal character #{c.inspect} in raw string #{string.inspect}"
end end
end end
else else
@ -145,7 +145,7 @@ module REXML
case c.unpack('U') case c.unpack('U')
when *VALID_CHAR when *VALID_CHAR
else else
raise "Illegal character #{c.inspect} in raw string \"#{string}\"" raise "Illegal character #{c.inspect} in raw string #{string.inspect}"
end end
end end
end end
@ -154,13 +154,13 @@ module REXML
# context sensitive # context sensitive
string.scan(pattern) do string.scan(pattern) do
if $1[-1] != ?; if $1[-1] != ?;
raise "Illegal character '#{$1}' in raw string \"#{string}\"" raise "Illegal character #{$1.inspect} in raw string #{string.inspect}"
elsif $1[0] == ?& elsif $1[0] == ?&
if $5 and $5[0] == ?# if $5 and $5[0] == ?#
case ($5[1] == ?x ? $5[2..-1].to_i(16) : $5[1..-1].to_i) case ($5[1] == ?x ? $5[2..-1].to_i(16) : $5[1..-1].to_i)
when *VALID_CHAR when *VALID_CHAR
else else
raise "Illegal character '#{$1}' in raw string \"#{string}\"" raise "Illegal character #{$1.inspect} in raw string #{string.inspect}"
end end
# FIXME: below can't work but this needs API change. # FIXME: below can't work but this needs API change.
# elsif @parent and $3 and !SUBSTITUTES.include?($1) # elsif @parent and $3 and !SUBSTITUTES.include?($1)