summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTakashi Kokubun <takashikkbn@gmail.com>2022-11-25 21:32:20 -0800
committergit <svn-admin@ruby-lang.org>2022-11-26 05:32:25 +0000
commit574896a0ce99ab00676aa5ff2fabd3dcf8d49154 (patch)
treed31ed953a4b728256af46749617e33a13118e783 /lib
parent15be9ecbcc15c1038e1e148780e38cb0ec3e1034 (diff)
[ruby/erb] Define ERB::Escape module
(https://github.com/ruby/erb/pull/38) Close #32
Diffstat (limited to 'lib')
-rw-r--r--lib/erb/util.rb22
1 files changed, 15 insertions, 7 deletions
diff --git a/lib/erb/util.rb b/lib/erb/util.rb
index 97f5abbba0..c24a175199 100644
--- a/lib/erb/util.rb
+++ b/lib/erb/util.rb
@@ -1,8 +1,20 @@
+#--
+# ERB::Escape
+#
+# A subset of ERB::Util. Unlike ERB::Util#html_escape, we expect/hope
+# Rails will not monkey-patch ERB::Escape#html_escape.
begin
- # ERB::Util.html_escape
require 'erb/escape'
rescue LoadError # JRuby can't load .so
end
+unless defined?(ERB::Escape) # JRuby
+ module ERB::Escape
+ def html_escape(s)
+ CGI.escapeHTML(s.to_s)
+ end
+ module_function :html_escape
+ end
+end
#--
# ERB::Util
@@ -21,12 +33,8 @@ module ERB::Util
#
# is a &gt; 0 &amp; a &lt; 10?
#
- unless defined?(ERB::Util.html_escape) # for JRuby
- def html_escape(s)
- CGI.escapeHTML(s.to_s)
- end
- module_function :html_escape
- end
+ include ERB::Escape # html_escape
+ module_function :html_escape
alias h html_escape
module_function :h