File tree Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -49,9 +49,12 @@ def escapeHTML(string)
4949 table = Hash [ TABLE_FOR_ESCAPE_HTML__ . map { |pair |pair . map { |s |s . encode ( enc ) } } ]
5050 string = string . gsub ( /#{ "['&\" <>]" . encode ( enc ) } / , table )
5151 string . encode! ( origenc ) if origenc
52- return string
52+ string
53+ else
54+ string = string . b
55+ string . gsub! ( /['&\" <>]/ , TABLE_FOR_ESCAPE_HTML__ )
56+ string . force_encoding ( enc )
5357 end
54- string . gsub ( /['&\" <>]/ , TABLE_FOR_ESCAPE_HTML__ )
5558 end
5659
5760 begin
@@ -90,7 +93,8 @@ def unescapeHTML(string)
9093 when Encoding ::ISO_8859_1 ; 256
9194 else 128
9295 end
93- string . gsub ( /&(apos|amp|quot|gt|lt|\# [0-9]+|\# [xX][0-9A-Fa-f]+);/ ) do
96+ string = string . b
97+ string . gsub! ( /&(apos|amp|quot|gt|lt|\# [0-9]+|\# [xX][0-9A-Fa-f]+);/ ) do
9498 match = $1. dup
9599 case match
96100 when 'apos' then "'"
@@ -116,6 +120,7 @@ def unescapeHTML(string)
116120 "&#{ match } ;"
117121 end
118122 end
123+ string . force_encoding enc
119124 end
120125
121126 # Synonym for CGI.escapeHTML(str)
You can’t perform that action at this time.
0 commit comments