aboutsummaryrefslogtreecommitdiffstats
path: root/lib/cgi.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/cgi.rb')
-rw-r--r--lib/cgi.rb8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/cgi.rb b/lib/cgi.rb
index 52502b3114..7997a58f4c 100644
--- a/lib/cgi.rb
+++ b/lib/cgi.rb
@@ -355,12 +355,18 @@ class CGI
end
end
+ TABLE_FOR_ESCAPE_HTML__ = {
+ '&' => '&',
+ '"' => '"',
+ '<' => '&lt;',
+ '>' => '&gt;',
+ }
# Escape special characters in HTML, namely &\"<>
# CGI::escapeHTML('Usage: foo "bar" <baz>')
# # => "Usage: foo &quot;bar&quot; &lt;baz&gt;"
def CGI::escapeHTML(string)
- string.gsub(/&/, '&amp;').gsub(/\"/, '&quot;').gsub(/>/, '&gt;').gsub(/</, '&lt;')
+ string.gsub(/[&\"<>]/, TABLE_FOR_ESCAPE_HTML__)
end