aboutsummaryrefslogtreecommitdiffstats
path: root/test/rexml
diff options
context:
space:
mode:
authorkou <kou@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-06-07 13:01:28 +0000
committerkou <kou@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-06-07 13:01:28 +0000
commitd311921d31e575e0e72f67dfa27fd90b2cfc5ec4 (patch)
tree472347b1730f01149c46bd5c3b6466576c5746a0 /test/rexml
parentc2127d0a03745f08abd3c6758cd42089c5763117 (diff)
downloadruby-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 'test/rexml')
-rw-r--r--test/rexml/parser/test_stream.rb32
1 files changed, 32 insertions, 0 deletions
diff --git a/test/rexml/parser/test_stream.rb b/test/rexml/parser/test_stream.rb
new file mode 100644
index 0000000000..c315833e4b
--- /dev/null
+++ b/test/rexml/parser/test_stream.rb
@@ -0,0 +1,32 @@
+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