lib/review/htmlutils.rb in review-4.2.0 vs lib/review/htmlutils.rb in review-5.0.0
- old
+ new
@@ -5,22 +5,19 @@
# This program is free software.
# You can distribute or modify this program under the terms of
# the GNU LGPL, Lesser General Public License version 2.1.
#
-require 'cgi/util'
+begin
+ require 'cgi/escape'
+rescue
+ require 'cgi/util'
+end
+
module ReVIEW
module HTMLUtils
- ESC = {
- '&' => '&',
- '<' => '<',
- '>' => '>',
- '"' => '"'
- } # .freeze
-
def escape(str)
- t = ESC
- str.gsub(/[&"<>]/) { |c| t[c] }
+ CGI.escapeHTML(str)
end
alias_method :escape_html, :escape # for backward compatibility
alias_method :h, :escape