diff options
author | kou <kou@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-06-07 13:01:28 +0000 |
---|---|---|
committer | kou <kou@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-06-07 13:01:28 +0000 |
commit | d311921d31e575e0e72f67dfa27fd90b2cfc5ec4 (patch) | |
tree | 472347b1730f01149c46bd5c3b6466576c5746a0 /lib/rexml/parsers | |
parent | c2127d0a03745f08abd3c6758cd42089c5763117 (diff) | |
download | ruby-d311921d31e575e0e72f67dfa27fd90b2cfc5ec4.tar.gz |
rexml: add close tag check on end of document to StreamParser
[ruby-core:81593] [Bug #13636]
Reported by Anton Sivakov. Thanks!!!
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59033 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rexml/parsers')
-rw-r--r-- | lib/rexml/parsers/streamparser.rb | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/rexml/parsers/streamparser.rb b/lib/rexml/parsers/streamparser.rb index b271e6743e..f6a8bfa802 100644 --- a/lib/rexml/parsers/streamparser.rb +++ b/lib/rexml/parsers/streamparser.rb @@ -7,6 +7,7 @@ module REXML def initialize source, listener @listener = listener @parser = BaseParser.new( source ) + @tag_stack = [] end def add_listener( listener ) @@ -19,14 +20,21 @@ module REXML 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 ) |