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

ruby-changes:47124

From: usa <ko1@a...>
Date: Fri, 30 Jun 2017 21:58:46 +0900 (JST)
Subject: [ruby-changes:47124] usa:r59239 (ruby_2_3): merge revision(s) 59033, 59034: [Backport #13636]

usa	2017-06-30 21:58:41 +0900 (Fri, 30 Jun 2017)

  New Revision: 59239

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=59239

  Log:
    merge revision(s) 59033,59034: [Backport #13636]
    
    rexml: add close tag check on end of document to StreamParser
    
    [ruby-core:81593] [Bug #13636]
    
    Reported by Anton Sivakov. Thanks!!!
    
    * properties.

  Added files:
    branches/ruby_2_3/test/rexml/parser/test_stream.rb
  Modified directories:
    branches/ruby_2_3/
  Modified files:
    branches/ruby_2_3/ChangeLog
    branches/ruby_2_3/lib/rexml/parsers/streamparser.rb
    branches/ruby_2_3/version.h
Index: ruby_2_3/lib/rexml/parsers/streamparser.rb
===================================================================
--- ruby_2_3/lib/rexml/parsers/streamparser.rb	(revision 59238)
+++ ruby_2_3/lib/rexml/parsers/streamparser.rb	(revision 59239)
@@ -7,6 +7,7 @@ module REXML https://github.com/ruby/ruby/blob/trunk/ruby_2_3/lib/rexml/parsers/streamparser.rb#L7
       def initialize source, listener
         @listener = listener
         @parser = BaseParser.new( source )
+        @tag_stack = []
       end
 
       def add_listener( listener )
@@ -19,14 +20,21 @@ module REXML https://github.com/ruby/ruby/blob/trunk/ruby_2_3/lib/rexml/parsers/streamparser.rb#L20
           event = @parser.pull
           case event[0]
           when :end_document
+            unless @tag_stack.empty?
+              tag_path = "/" + @tag_stack.join("/")
+              raise ParseException.new("Missing end tag for '#{tag_path}'",
+                                       @parser.source)
+            end
             return
           when :start_element
+            @tag_stack << event[1]
             attrs = event[2].each do |n, v|
               event[2][n] = @parser.unnormalize( v )
             end
             @listener.tag_start( event[1], attrs )
           when :end_element
             @listener.tag_end( event[1] )
+            @tag_stack.pop
           when :text
             normalized = @parser.unnormalize( event[1] )
             @listener.text( normalized )
Index: ruby_2_3/version.h
===================================================================
--- ruby_2_3/version.h	(revision 59238)
+++ ruby_2_3/version.h	(revision 59239)
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_3/version.h#L1
 #define RUBY_VERSION "2.3.5"
 #define RUBY_RELEASE_DATE "2017-06-30"
-#define RUBY_PATCHLEVEL 335
+#define RUBY_PATCHLEVEL 336
 
 #define RUBY_RELEASE_YEAR 2017
 #define RUBY_RELEASE_MONTH 6
Index: ruby_2_3/test/rexml/parser/test_stream.rb
===================================================================
--- ruby_2_3/test/rexml/parser/test_stream.rb	(nonexistent)
+++ ruby_2_3/test/rexml/parser/test_stream.rb	(revision 59239)
@@ -0,0 +1,32 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_3/test/rexml/parser/test_stream.rb#L1
+require "test/unit"
+require "rexml/document"
+require "rexml/streamlistener"
+
+module REXMLTests
+  class TestStreamParser < Test::Unit::TestCase
+    class NullListener
+      include REXML::StreamListener
+    end
+
+    class TestInvalid < self
+      def test_no_end_tag
+        xml = "<root><sub>"
+        exception = assert_raise(REXML::ParseException) do
+          parse(xml)
+        end
+        assert_equal(<<-MESSAGE, exception.to_s)
+Missing end tag for '/root/sub'
+Line: 1
+Position: #{xml.bytesize}
+Last 80 unconsumed characters:
+        MESSAGE
+      end
+
+      private
+      def parse(xml, listener=nil)
+        listener ||= NullListener.new
+        REXML::Document.parse_stream(xml, listener)
+      end
+    end
+  end
+end

Property changes on: ruby_2_3/test/rexml/parser/test_stream.rb
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+LF
\ No newline at end of property
Index: ruby_2_3/ChangeLog
===================================================================
--- ruby_2_3/ChangeLog	(revision 59238)
+++ ruby_2_3/ChangeLog	(revision 59239)
@@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_3/ChangeLog#L1
+Fri Jun 30 21:57:27 2017  Kouhei Sutou  <kou@c...>
+
+	* lib/rexml/parsers/streamparser.rb: add close tag check on end of
+	  document to StreamParser [Bug #13636]
+	  Reported by Anton Sivakov. Thanks!!!
+
 Fri Jun 30 21:54:01 2017  Nobuyoshi Nakada  <nobu@r...>
 
 	* array.c (rb_ary_insert): check position to insert even if no elements
Index: ruby_2_3
===================================================================
--- ruby_2_3	(revision 59238)
+++ ruby_2_3	(revision 59239)

Property changes on: ruby_2_3
___________________________________________________________________
Modified: svn:mergeinfo
## -0,0 +0,1 ##
   Merged /trunk:r59033-59034

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

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