File tree Expand file tree Collapse file tree 2 files changed +18
-10
lines changed
Expand file tree Collapse file tree 2 files changed +18
-10
lines changed Original file line number Diff line number Diff line change 11#include "ruby.h"
22#include "ruby/encoding.h"
33
4- static VALUE rb_cERB , rb_mUtil , rb_cCGI ;
4+ static VALUE rb_cERB , rb_mEscape , rb_cCGI ;
55static ID id_escapeHTML ;
66
77#define HTML_ESCAPE_MAX_LEN 6
8787Init_escape (void )
8888{
8989 rb_cERB = rb_define_class ("ERB" , rb_cObject );
90- rb_mUtil = rb_define_module_under (rb_cERB , "Util " );
91- rb_define_module_function (rb_mUtil , "html_escape" , erb_escape_html , 1 );
90+ rb_mEscape = rb_define_module_under (rb_cERB , "Escape " );
91+ rb_define_module_function (rb_mEscape , "html_escape" , erb_escape_html , 1 );
9292
9393 rb_cCGI = rb_define_class ("CGI" , rb_cObject );
9494 id_escapeHTML = rb_intern ("escapeHTML" );
Original file line number Diff line number Diff line change 1+ #--
2+ # ERB::Escape
3+ #
4+ # A subset of ERB::Util. Unlike ERB::Util#html_escape, we expect/hope
5+ # Rails will not monkey-patch ERB::Escape#html_escape.
16begin
2- # ERB::Util.html_escape
37 require 'erb/escape'
48rescue LoadError # JRuby can't load .so
59end
10+ unless defined? ( ERB ::Escape ) # JRuby
11+ module ERB ::Escape
12+ def html_escape ( s )
13+ CGI . escapeHTML ( s . to_s )
14+ end
15+ module_function :html_escape
16+ end
17+ end
618
719#--
820# ERB::Util
@@ -21,12 +33,8 @@ module ERB::Util
2133 #
2234 # is a > 0 & a < 10?
2335 #
24- unless defined? ( ERB ::Util . html_escape ) # for JRuby
25- def html_escape ( s )
26- CGI . escapeHTML ( s . to_s )
27- end
28- module_function :html_escape
29- end
36+ include ERB ::Escape # html_escape
37+ module_function :html_escape
3038 alias h html_escape
3139 module_function :h
3240
You can’t perform that action at this time.
0 commit comments