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

ruby-changes:30437

From: kou <ko1@a...>
Date: Sun, 11 Aug 2013 18:09:30 +0900 (JST)
Subject: [ruby-changes:30437] kou:r42516 (trunk): * lib/rexml/parsers/sax2parser.rb (REXML::Parsers::SAX2Parser#parse):

kou	2013-08-11 18:09:25 +0900 (Sun, 11 Aug 2013)

  New Revision: 42516

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

  Log:
    * lib/rexml/parsers/sax2parser.rb (REXML::Parsers::SAX2Parser#parse):
      Support NDATA in external entity declaration.
    * test/rexml/parser/test_sax2.rb: Add tests for the above case.

  Modified files:
    trunk/ChangeLog
    trunk/lib/rexml/parsers/sax2parser.rb
    trunk/test/rexml/parser/test_sax2.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 42515)
+++ ChangeLog	(revision 42516)
@@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sun Aug 11 18:08:40 2013  Kouhei Sutou  <kou@c...>
+
+	* lib/rexml/parsers/sax2parser.rb (REXML::Parsers::SAX2Parser#parse):
+	  Support NDATA in external entity declaration.
+	* test/rexml/parser/test_sax2.rb: Add tests for the above case.
+
 Sun Aug 11 18:07:39 2013  Kouhei Sutou  <kou@c...>
 
 	* lib/rexml/parsers/baseparser.rb
Index: lib/rexml/parsers/sax2parser.rb
===================================================================
--- lib/rexml/parsers/sax2parser.rb	(revision 42515)
+++ lib/rexml/parsers/sax2parser.rb	(revision 42516)
@@ -177,6 +177,12 @@ 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
+            case event[2]
+            when "SYSTEM"
+              event[4, 0] = "NDATA" if event.size == 5
+            when "PUBLIC"
+              event[5, 0] = "NDATA" if event.size == 6
+            end
             handle( event[0], event[1..-1] )
           when :processing_instruction, :comment, :attlistdecl,
             :elementdecl, :cdata, :notationdecl, :xmldecl
Index: test/rexml/parser/test_sax2.rb
===================================================================
--- test/rexml/parser/test_sax2.rb	(revision 42515)
+++ test/rexml/parser/test_sax2.rb	(revision 42516)
@@ -54,6 +54,18 @@ class TestSAX2Parser < Test::Unit::TestC https://github.com/ruby/ruby/blob/trunk/test/rexml/parser/test_sax2.rb#L54
 
         class TestExternlID < self
           class TestSystem < self
+            def test_with_ndata
+              declaration = [
+                "name",
+                "SYSTEM", "system-literal",
+                "NDATA", "ndata-name",
+              ]
+              assert_equal([declaration],
+                           parse(<<-INTERNAL_SUBSET))
+<!ENTITY name SYSTEM "system-literal" NDATA ndata-name>
+              INTERNAL_SUBSET
+            end
+
             def test_without_ndata
               declaration = [
                 "name",
@@ -67,6 +79,18 @@ class TestSAX2Parser < Test::Unit::TestC https://github.com/ruby/ruby/blob/trunk/test/rexml/parser/test_sax2.rb#L79
           end
 
           class TestPublic < self
+            def test_with_ndata
+              declaration = [
+                "name",
+                "PUBLIC", "public-literal", "system-literal",
+                "NDATA", "ndata-name",
+              ]
+              assert_equal([declaration],
+                           parse(<<-INTERNAL_SUBSET))
+<!ENTITY name PUBLIC "public-literal" "system-literal" NDATA ndata-name>
+              INTERNAL_SUBSET
+            end
+
             def test_without_ndata
               declaration = [
                 "name",

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

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