diff --git a/ChangeLog b/ChangeLog index 2a15949f61..c7f16d7093 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Mon Aug 13 13:13:19 2012 Shugo Maeda + + * lib/erb.rb (ERB::Util.html_escape): use CGI.escape to escape + single quotes. [ruby-core:47138] [Bug #6861] + Sun Aug 12 11:57:20 2012 Kazuki Tsujimoto * vm.c (invoke_block_from_c): fix unintentional block passing. diff --git a/lib/erb.rb b/lib/erb.rb index bb47943a86..d30911e0f1 100644 --- a/lib/erb.rb +++ b/lib/erb.rb @@ -10,6 +10,8 @@ # # You can redistribute it and/or modify it under the same terms as Ruby. +require "cgi/util" + # # = ERB -- Ruby Templating # @@ -909,7 +911,7 @@ class ERB # is a > 0 & a < 10? # def html_escape(s) - s.to_s.gsub(/&/, "&").gsub(/\"/, """).gsub(/>/, ">").gsub(/?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~")) + + assert_equal("", ERB::Util.html_escape("")) + assert_equal("abc", ERB::Util.html_escape("abc")) + assert_equal("<<", ERB::Util.html_escape("<<")) + end end class TestERBCore < Test::Unit::TestCase