diff options
Diffstat (limited to 'lib/cgi.rb')
-rw-r--r-- | lib/cgi.rb | 8 |
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__ = { + '&' => '&', + '"' => '"', + '<' => '<', + '>' => '>', + } # Escape special characters in HTML, namely &\"<> # CGI::escapeHTML('Usage: foo "bar" <baz>') # # => "Usage: foo "bar" <baz>" def CGI::escapeHTML(string) - string.gsub(/&/, '&').gsub(/\"/, '"').gsub(/>/, '>').gsub(/</, '<') + string.gsub(/[&\"<>]/, TABLE_FOR_ESCAPE_HTML__) end |