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

ruby-changes:30435

From: kou <ko1@a...>
Date: Sun, 11 Aug 2013 18:01:47 +0900 (JST)
Subject: [ruby-changes:30435] kou:r42514 (trunk): * NEWS (REXML::Parsers::SAX2Parser): Add about this change.

kou	2013-08-11 18:01:41 +0900 (Sun, 11 Aug 2013)

  New Revision: 42514

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

  Log:
    * NEWS (REXML::Parsers::SAX2Parser): Add about this change.
    * lib/rexml/parsers/sax2parser.rb (REXML::Parsers::SAX2Parser#parse):
      Fix wrong number of arguments. Document says "an array of the
      entity declaration" but it passes two or more arguments.
      This is a bug but it break backward compatibility.
      Reported by Ippei Obayashi. [Bug #8731] [ruby-dev:47582]
    * lib/rexml/sax2listener.rb (REXML::SAX2Listener#entitydecl): ditto.
      The listener template accepted two arguments.
    * test/rexml/parser/test_sax2.rb: Add tests for external ID case.

  Modified files:
    trunk/NEWS
    trunk/lib/rexml/parsers/sax2parser.rb
    trunk/lib/rexml/sax2listener.rb
    trunk/test/rexml/parser/test_sax2.rb
Index: lib/rexml/parsers/sax2parser.rb
===================================================================
--- lib/rexml/parsers/sax2parser.rb	(revision 42513)
+++ lib/rexml/parsers/sax2parser.rb	(revision 42514)
@@ -177,7 +177,7 @@ module REXML https://github.com/ruby/ruby/blob/trunk/lib/rexml/parsers/sax2parser.rb#L177
             handle( :characters, copy )
           when :entitydecl
             @entities[ event[1] ] = event[2] if event.size == 3
-            handle( *event )
+            handle( event[0], event[1..-1] )
           when :processing_instruction, :comment, :attlistdecl,
             :elementdecl, :cdata, :notationdecl, :xmldecl
             handle( *event )
Index: lib/rexml/sax2listener.rb
===================================================================
--- lib/rexml/sax2listener.rb	(revision 42513)
+++ lib/rexml/sax2listener.rb	(revision 42514)
@@ -70,7 +70,7 @@ module REXML https://github.com/ruby/ruby/blob/trunk/lib/rexml/sax2listener.rb#L70
     #  ["open-hatch", "PUBLIC", "\"-//Textuality//TEXT Standard open-hatch boilerplate//EN\"", "\"http://www.textuality.com/boilerplate/OpenHatch.xml\""]
     #  <!ENTITY hatch-pic SYSTEM "../grafix/OpenHatch.gif" NDATA gif>
     #  ["hatch-pic", "SYSTEM", "\"../grafix/OpenHatch.gif\"", "\n\t\t\t\t\t\t\tNDATA gif", "gif"]
-    def entitydecl name, decl
+    def entitydecl declaration
     end
     # <!NOTATION ...>
     def notationdecl content
Index: NEWS
===================================================================
--- NEWS	(revision 42513)
+++ NEWS	(revision 42514)
@@ -182,6 +182,12 @@ with all sufficient information, see the https://github.com/ruby/ruby/blob/trunk/NEWS#L182
 * REXML::Parsers::StreamParser
   * Supports "entity" event.
 
+* REXML::Parsers::SAX2Parser
+  * Fixes wrong number of arguments of entitydecl event. Document of the event
+    says "an array of the entity declaration" but implemenation passes two
+    or more arguments. It is an implementation bug but it breaks backword
+    compatibility.
+
 * REXML::Text
   * REXML::Text#<< supports method chain like 'text << "XXX" << "YYY"'.
   * REXML::Text#<< supports not "raw" mode.
Index: test/rexml/parser/test_sax2.rb
===================================================================
--- test/rexml/parser/test_sax2.rb	(revision 42513)
+++ test/rexml/parser/test_sax2.rb	(revision 42514)
@@ -22,9 +22,9 @@ class TestSAX2Parser < Test::Unit::TestC https://github.com/ruby/ruby/blob/trunk/test/rexml/parser/test_sax2.rb#L22
           @entity_declarations = []
         end
 
-        def entitydecl(*args)
+        def entitydecl(declaration)
           super
-          @entity_declarations << args
+          @entity_declarations << declaration
         end
       end
 
@@ -51,6 +51,33 @@ class TestSAX2Parser < Test::Unit::TestC https://github.com/ruby/ruby/blob/trunk/test/rexml/parser/test_sax2.rb#L51
             INTERNAL_SUBSET
           end
         end
+
+        class TestExternlID < self
+          class TestSystem < self
+            def test_without_ndata
+              declaration = [
+                "name",
+                "SYSTEM", "system-literal",
+              ]
+              assert_equal([declaration],
+                           parse(<<-INTERNAL_SUBSET))
+<!ENTITY name SYSTEM "system-literal">
+              INTERNAL_SUBSET
+            end
+          end
+
+          class TestPublic < self
+            def test_without_ndata
+              declaration = [
+                "name",
+                "PUBLIC", "public-literal", "system-literal",
+              ]
+              assert_equal([declaration], parse(<<-INTERNAL_SUBSET))
+<!ENTITY name PUBLIC "public-literal" "system-literal">
+              INTERNAL_SUBSET
+            end
+          end
+        end
       end
     end
   end

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

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