[前][次][番号順一覧][スレッド一覧]

ruby-changes:24254

From: xibbar <ko1@a...>
Date: Wed, 4 Jul 2012 13:42:43 +0900 (JST)
Subject: [ruby-changes:24254] xibbar:r36305 (trunk): * lib/cgi/util.rb: revert 36299: &apos; is XML specification.

xibbar	2012-07-04 13:42:35 +0900 (Wed, 04 Jul 2012)

  New Revision: 36305

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=36305

  Log:
    * lib/cgi/util.rb: revert 36299: &apos; is XML specification.

  Modified files:
    trunk/lib/cgi/util.rb
    trunk/test/cgi/test_cgi_util.rb

Index: lib/cgi/util.rb
===================================================================
--- lib/cgi/util.rb	(revision 36304)
+++ lib/cgi/util.rb	(revision 36305)
@@ -22,7 +22,6 @@
 
   # The set of special characters and their escaped values
   TABLE_FOR_ESCAPE_HTML__ = {
-    "'" => '&apos;',
     '&' => '&amp;',
     '"' => '&quot;',
     '<' => '&lt;',
@@ -33,7 +32,7 @@
   #   CGI::escapeHTML('Usage: foo "bar" <baz>')
   #      # => "Usage: foo &quot;bar&quot; &lt;baz&gt;"
   def CGI::escapeHTML(string)
-    string.gsub(/['&\"<>]/, TABLE_FOR_ESCAPE_HTML__)
+    string.gsub(/[&\"<>]/, TABLE_FOR_ESCAPE_HTML__)
   end
 
   # Unescape a string that has been HTML-escaped
@@ -42,9 +41,8 @@
   def CGI::unescapeHTML(string)
     enc = string.encoding
     if [Encoding::UTF_16BE, Encoding::UTF_16LE, Encoding::UTF_32BE, Encoding::UTF_32LE].include?(enc)
-      return string.gsub(Regexp.new('&(apos|amp|quot|gt|lt|#[0-9]+|#x[0-9A-Fa-f]+);'.encode(enc))) do
+      return string.gsub(Regexp.new('&(amp|quot|gt|lt|#[0-9]+|#x[0-9A-Fa-f]+);'.encode(enc))) do
         case $1.encode("US-ASCII")
-        when 'apos'                then "'".encode(enc)
         when 'amp'                 then '&'.encode(enc)
         when 'quot'                then '"'.encode(enc)
         when 'gt'                  then '>'.encode(enc)
@@ -55,10 +53,9 @@
       end
     end
     asciicompat = Encoding.compatible?(string, "a")
-    string.gsub(/&(apos|amp|quot|gt|lt|\#[0-9]+|\#x[0-9A-Fa-f]+);/) do
+    string.gsub(/&(amp|quot|gt|lt|\#[0-9]+|\#x[0-9A-Fa-f]+);/) do
       match = $1.dup
       case match
-      when 'apos'                then "'"
       when 'amp'                 then '&'
       when 'quot'                then '"'
       when 'gt'                  then '>'
Index: test/cgi/test_cgi_util.rb
===================================================================
--- test/cgi/test_cgi_util.rb	(revision 36304)
+++ test/cgi/test_cgi_util.rb	(revision 36305)
@@ -53,8 +53,4 @@
     assert_equal("<HTML>\n\t<BODY>\n\t</BODY>\n</HTML>\n",CGI::pretty("<HTML><BODY></BODY></HTML>","\t"))
   end
 
-  def test_cgi_unescapeHTML
-    assert_equal(CGI::unescapeHTML("&apos;&amp;&quot;&gt;&lt;"),"'&\"><")
-  end
-
 end

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]