summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog8
-rw-r--r--lib/rexml/parsers/treeparser.rb4
-rw-r--r--test/rexml/parser/test_tree.rb13
3 files changed, 23 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 99b39170c1..2e7aaa0049 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+Tue Sep 3 22:59:58 2013 Kouhei Sutou <kou@cozmixng.org>
+
+ * 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@cozmixng.org>
* test/rexml/parser/test_tree.rb: Fix test name to describe test
diff --git a/lib/rexml/parsers/treeparser.rb b/lib/rexml/parsers/treeparser.rb
index 4dd1b90590..68edb77759 100644
--- a/lib/rexml/parsers/treeparser.rb
+++ b/lib/rexml/parsers/treeparser.rb
@@ -24,8 +24,8 @@ module REXML
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
diff --git a/test/rexml/parser/test_tree.rb b/test/rexml/parser/test_tree.rb
index 7720e9531a..6754e6bb59 100644
--- a/test/rexml/parser/test_tree.rb
+++ b/test/rexml/parser/test_tree.rb
@@ -17,6 +17,19 @@ Last 80 unconsumed characters:
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