File tree 3 files changed +16
-17
lines changed
3 files changed +16
-17
lines changed Original file line number Diff line number Diff line change 8
8
/tmp /
9
9
Gemfile.lock
10
10
* .so
11
+ * .bundle
11
12
* .gem
Original file line number Diff line number Diff line change 1
1
#include "ruby.h"
2
2
#include "ruby/encoding.h"
3
3
4
- static VALUE rb_cERB , rb_mEscape ;
4
+ static VALUE rb_cERB , rb_mUtil , rb_cCGI ;
5
+ static ID id_escapeHTML ;
5
6
6
7
#define HTML_ESCAPE_MAX_LEN 6
7
8
@@ -76,14 +77,17 @@ erb_escape_html(VALUE self, VALUE str)
76
77
return optimized_escape_html (str );
77
78
}
78
79
else {
79
- return rb_call_super ( 1 , & str );
80
+ return rb_funcall ( rb_cCGI , id_escapeHTML , 1 , str );
80
81
}
81
82
}
82
83
83
84
void
84
85
Init_erb (void )
85
86
{
86
87
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" );
89
93
}
Original file line number Diff line number Diff line change @@ -998,20 +998,14 @@ module Util
998
998
#
999
999
# is a > 0 & a < 10?
1000
1000
#
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
1003
1008
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
1015
1009
alias h html_escape
1016
1010
module_function :h
1017
1011
module_function :html_escape
You can’t perform that action at this time.
0 commit comments