File tree Expand file tree Collapse file tree 2 files changed +15
-17
lines changed
Expand file tree Collapse file tree 2 files changed +15
-17
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_mEscape ;
4+ static VALUE rb_cERB , rb_mUtil , rb_cCGI ;
5+ static ID id_escapeHTML ;
56
67#define HTML_ESCAPE_MAX_LEN 6
78
@@ -76,14 +77,17 @@ erb_escape_html(VALUE self, VALUE str)
7677 return optimized_escape_html (str );
7778 }
7879 else {
79- return rb_call_super ( 1 , & str );
80+ return rb_funcall ( rb_cCGI , id_escapeHTML , 1 , str );
8081 }
8182}
8283
8384void
8485Init_erb (void )
8586{
8687 rb_cERB = rb_define_class ("ERB" , rb_cObject );
87- rb_mEscape = rb_define_module_under (rb_cERB , "Escape" );
88- rb_define_method (rb_mEscape , "html_escape" , erb_escape_html , 1 );
88+ rb_mUtil = rb_define_module_under (rb_cERB , "Util" );
89+ rb_define_method (rb_mUtil , "html_escape" , erb_escape_html , 1 );
90+
91+ rb_cCGI = rb_define_class ("CGI" , rb_cObject );
92+ id_escapeHTML = rb_intern ("escapeHTML" );
8993}
Original file line number Diff line number Diff line change @@ -998,20 +998,14 @@ module Util
998998 #
999999 # is a > 0 & a < 10?
10001000 #
1001- def html_escape ( s )
1002- CGI . escapeHTML ( s . to_s )
1001+ begin
1002+ # ERB::Util.html_escape
1003+ require 'erb.so'
1004+ rescue LoadError
1005+ def html_escape ( s )
1006+ CGI . escapeHTML ( s . to_s )
1007+ end
10031008 end
1004- end
1005-
1006- begin
1007- require 'erb.so'
1008- rescue LoadError
1009- else
1010- private_constant :Escape
1011- Util . prepend ( Escape )
1012- end
1013-
1014- module Util
10151009 alias h html_escape
10161010 module_function :h
10171011 module_function :html_escape
You can’t perform that action at this time.
0 commit comments