aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog8
-rw-r--r--lib/cgi/util.rb16
-rw-r--r--test/cgi/test_cgi_util.rb15
3 files changed, 27 insertions, 12 deletions
diff --git a/ChangeLog b/ChangeLog
index 754e40eca7..9ff32ab932 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+Sat Mar 22 06:46:16 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * 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@iDaemons.org>
* configure.in: Fix a build problem with clang and --with-opt-dir.
diff --git a/lib/cgi/util.rb b/lib/cgi/util.rb
index 199e17bbbc..3d7db8f2c8 100644
--- a/lib/cgi/util.rb
+++ b/lib/cgi/util.rb
@@ -90,14 +90,10 @@ module CGI::Util
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
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 ]
diff --git a/test/cgi/test_cgi_util.rb b/test/cgi/test_cgi_util.rb
index c0cd4c7eb1..802379d233 100644
--- a/test/cgi/test_cgi_util.rb
+++ b/test/cgi/test_cgi_util.rb
@@ -86,4 +86,19 @@ class CGIUtilTest < Test::Unit::TestCase
def test_cgi_include_unescapeHTML
assert_equal(unescapeHTML("&#39;&amp;&quot;&gt;&lt;"),"'&\"><")
end
+
+ def test_cgi_escapeElement
+ assert_equal("<BR>&lt;A HREF=&quot;url&quot;&gt;&lt;/A&gt;", escapeElement('<BR><A HREF="url"></A>', "A", "IMG"))
+ assert_equal("<BR>&lt;A HREF=&quot;url&quot;&gt;&lt;/A&gt;", escapeElement('<BR><A HREF="url"></A>', ["A", "IMG"]))
+ assert_equal("<BR>&lt;A HREF=&quot;url&quot;&gt;&lt;/A&gt;", escape_element('<BR><A HREF="url"></A>', "A", "IMG"))
+ assert_equal("<BR>&lt;A HREF=&quot;url&quot;&gt;&lt;/A&gt;", escape_element('<BR><A HREF="url"></A>', ["A", "IMG"]))
+ end
+
+
+ def test_cgi_unescapeElement
+ assert_equal('&lt;BR&gt;<A HREF="url"></A>', unescapeElement(escapeHTML('<BR><A HREF="url"></A>'), "A", "IMG"))
+ assert_equal('&lt;BR&gt;<A HREF="url"></A>', unescapeElement(escapeHTML('<BR><A HREF="url"></A>'), ["A", "IMG"]))
+ assert_equal('&lt;BR&gt;<A HREF="url"></A>', unescape_element(escapeHTML('<BR><A HREF="url"></A>'), "A", "IMG"))
+ assert_equal('&lt;BR&gt;<A HREF="url"></A>', unescape_element(escapeHTML('<BR><A HREF="url"></A>'), ["A", "IMG"]))
+ end
end