ruby-changes:33303
From: nobu <ko1@a...>
Date: Sat, 22 Mar 2014 06:46:21 +0900 (JST)
Subject: [ruby-changes:33303] nobu:r45382 (trunk): cgi/util.rb: use alias
nobu 2014-03-22 06:46:17 +0900 (Sat, 22 Mar 2014) New Revision: 45382 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=45382 Log: cgi/util.rb: use alias * lib/cgi/util.rb (escape_html, unescape_html): make synonyms aliases instead of wrapper methods. * lib/cgi/util.rb (escape_element, unescape_element): ditto. [Fixes GH-573] Modified files: trunk/ChangeLog trunk/lib/cgi/util.rb trunk/test/cgi/test_cgi_util.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 45381) +++ ChangeLog (revision 45382) @@ -1,3 +1,11 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Sat Mar 22 06:46:16 2014 Nobuyoshi Nakada <nobu@r...> + + * lib/cgi/util.rb (escape_html, unescape_html): make synonyms + aliases instead of wrapper methods. + + * lib/cgi/util.rb (escape_element, unescape_element): ditto. + [Fixes GH-573] + Fri Mar 21 21:57:34 2014 Akinori MUSHA <knu@i...> * configure.in: Fix a build problem with clang and --with-opt-dir. Index: lib/cgi/util.rb =================================================================== --- lib/cgi/util.rb (revision 45381) +++ lib/cgi/util.rb (revision 45382) @@ -90,14 +90,10 @@ module CGI::Util https://github.com/ruby/ruby/blob/trunk/lib/cgi/util.rb#L90 end # Synonym for CGI::escapeHTML(str) - def escape_html(str) - escapeHTML(str) - end + alias escape_html escapeHTML # Synonym for CGI::unescapeHTML(str) - def unescape_html(str) - unescapeHTML(str) - end + alias unescape_html unescapeHTML # Escape only the tags of certain HTML elements in +string+. # @@ -144,14 +140,10 @@ module CGI::Util https://github.com/ruby/ruby/blob/trunk/lib/cgi/util.rb#L140 end # Synonym for CGI::escapeElement(str) - def escape_element(str) - escapeElement(str) - end + alias escape_element escapeElement # Synonym for CGI::unescapeElement(str) - def unescape_element(str) - unescapeElement(str) - end + alias unescape_element unescapeElement # Abbreviated day-of-week names specified by RFC 822 RFC822_DAYS = %w[ Sun Mon Tue Wed Thu Fri Sat ] Index: test/cgi/test_cgi_util.rb =================================================================== --- test/cgi/test_cgi_util.rb (revision 45381) +++ test/cgi/test_cgi_util.rb (revision 45382) @@ -86,4 +86,19 @@ class CGIUtilTest < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/cgi/test_cgi_util.rb#L86 def test_cgi_include_unescapeHTML assert_equal(unescapeHTML("'&"><"),"'&\"><") end + + def test_cgi_escapeElement + assert_equal("<BR><A HREF="url"></A>", escapeElement('<BR><A HREF="url"></A>', "A", "IMG")) + assert_equal("<BR><A HREF="url"></A>", escapeElement('<BR><A HREF="url"></A>', ["A", "IMG"])) + assert_equal("<BR><A HREF="url"></A>", escape_element('<BR><A HREF="url"></A>', "A", "IMG")) + assert_equal("<BR><A HREF="url"></A>", escape_element('<BR><A HREF="url"></A>', ["A", "IMG"])) + end + + + def test_cgi_unescapeElement + assert_equal('<BR><A HREF="url"></A>', unescapeElement(escapeHTML('<BR><A HREF="url"></A>'), "A", "IMG")) + assert_equal('<BR><A HREF="url"></A>', unescapeElement(escapeHTML('<BR><A HREF="url"></A>'), ["A", "IMG"])) + assert_equal('<BR><A HREF="url"></A>', unescape_element(escapeHTML('<BR><A HREF="url"></A>'), "A", "IMG")) + assert_equal('<BR><A HREF="url"></A>', unescape_element(escapeHTML('<BR><A HREF="url"></A>'), ["A", "IMG"])) + end end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/