Skip to content

Commit a124a19

Browse files
committed
use #inspect to print meta-characters in error messages
1 parent c0e3f14 commit a124a19

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lib/rexml/text.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,15 +137,15 @@ def Text.check string, pattern, doctype
137137
case c.ord
138138
when *VALID_CHAR
139139
else
140-
raise "Illegal character #{c.inspect} in raw string \"#{string}\""
140+
raise "Illegal character #{c.inspect} in raw string #{string.inspect}"
141141
end
142142
end
143143
else
144144
string.scan(/[\x00-\x7F]|[\x80-\xBF][\xC0-\xF0]*|[\xC0-\xF0]/n) do |c|
145145
case c.unpack('U')
146146
when *VALID_CHAR
147147
else
148-
raise "Illegal character #{c.inspect} in raw string \"#{string}\""
148+
raise "Illegal character #{c.inspect} in raw string #{string.inspect}"
149149
end
150150
end
151151
end
@@ -154,13 +154,13 @@ def Text.check string, pattern, doctype
154154
# context sensitive
155155
string.scan(pattern) do
156156
if $1[-1] != ?;
157-
raise "Illegal character '#{$1}' in raw string \"#{string}\""
157+
raise "Illegal character #{$1.inspect} in raw string #{string.inspect}"
158158
elsif $1[0] == ?&
159159
if $5 and $5[0] == ?#
160160
case ($5[1] == ?x ? $5[2..-1].to_i(16) : $5[1..-1].to_i)
161161
when *VALID_CHAR
162162
else
163-
raise "Illegal character '#{$1}' in raw string \"#{string}\""
163+
raise "Illegal character #{$1.inspect} in raw string #{string.inspect}"
164164
end
165165
# FIXME: below can't work but this needs API change.
166166
# elsif @parent and $3 and !SUBSTITUTES.include?($1)

0 commit comments

Comments
 (0)