ruby-changes:30736
From: kou <ko1@a...>
Date: Tue, 3 Sep 2013 23:01:28 +0900 (JST)
Subject: [ruby-changes:30736] kou:r42815 (trunk): * lib/rexml/parsers/treeparser.rb (REXML::Parsers::TreeParser#parse):
kou 2013-09-03 23:01:20 +0900 (Tue, 03 Sep 2013) New Revision: 42815 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=42815 Log: * lib/rexml/parsers/treeparser.rb (REXML::Parsers::TreeParser#parse): Add source information to parse exception on no close tag error. [Bug #8844] [ruby-dev:47672] Patch by Ippei Obayashi. Thanks!!! * test/rexml/parser/test_tree.rb: Add a test for the above case. Modified files: trunk/ChangeLog trunk/lib/rexml/parsers/treeparser.rb trunk/test/rexml/parser/test_tree.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 42814) +++ ChangeLog (revision 42815) @@ -1,3 +1,11 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Tue Sep 3 22:59:58 2013 Kouhei Sutou <kou@c...> + + * lib/rexml/parsers/treeparser.rb (REXML::Parsers::TreeParser#parse): + Add source information to parse exception on no close tag error. + [Bug #8844] [ruby-dev:47672] + Patch by Ippei Obayashi. Thanks!!! + * test/rexml/parser/test_tree.rb: Add a test for the above case. + Tue Sep 3 22:57:57 2013 Kouhei Sutou <kou@c...> * test/rexml/parser/test_tree.rb: Fix test name to describe test Index: lib/rexml/parsers/treeparser.rb =================================================================== --- lib/rexml/parsers/treeparser.rb (revision 42814) +++ lib/rexml/parsers/treeparser.rb (revision 42815) @@ -24,8 +24,8 @@ module REXML https://github.com/ruby/ruby/blob/trunk/lib/rexml/parsers/treeparser.rb#L24 case event[0] when :end_document unless tag_stack.empty? - #raise ParseException.new("No close tag for #{tag_stack.inspect}") - raise ParseException.new("No close tag for #{@build_context.xpath}") + raise ParseException.new("No close tag for #{@build_context.xpath}", + @parser.source, @parser) end return when :start_element Index: test/rexml/parser/test_tree.rb =================================================================== --- test/rexml/parser/test_tree.rb (revision 42814) +++ test/rexml/parser/test_tree.rb (revision 42815) @@ -17,6 +17,19 @@ Last 80 unconsumed characters: https://github.com/ruby/ruby/blob/trunk/test/rexml/parser/test_tree.rb#L17 MESSAGE end + def test_no_close_tag + xml = "<root>" + exception = assert_raise(REXML::ParseException) do + parse(xml) + end + assert_equal(<<-MESSAGE, exception.to_s) +No close tag for /root +Line: 1 +Position: #{xml.bytesize} +Last 80 unconsumed characters: + MESSAGE + end + private def parse(xml) document = REXML::Document.new -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/