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)
49
49
table = Hash [ TABLE_FOR_ESCAPE_HTML__ . map { |pair |pair . map { |s |s . encode ( enc ) } } ]
50
50
string = string . gsub ( /#{ "['&\" <>]" . encode ( enc ) } / , table )
51
51
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 )
53
57
end
54
- string . gsub ( /['&\" <>]/ , TABLE_FOR_ESCAPE_HTML__ )
55
58
end
56
59
57
60
begin
@@ -90,7 +93,8 @@ def unescapeHTML(string)
90
93
when Encoding ::ISO_8859_1 ; 256
91
94
else 128
92
95
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
94
98
match = $1. dup
95
99
case match
96
100
when 'apos' then "'"
@@ -116,6 +120,7 @@ def unescapeHTML(string)
116
120
"&#{ match } ;"
117
121
end
118
122
end
123
+ string . force_encoding enc
119
124
end
120
125
121
126
# Synonym for CGI.escapeHTML(str)
You can’t perform that action at this time.
0 commit comments