From: nagachika00@...
Date: 2017-07-23T07:33:12+00:00
Subject: [ruby-core:82129] [Ruby trunk Bug#13636] REXML::Document.parse_stream doesn't handle when closing tag not provided

Issue #13636 has been updated by nagachika (Tomoyuki Chikanaga).

Backport changed from 2.2: WONTFIX, 2.3: DONE, 2.4: REQUIRED to 2.2: WONTFIX, 2.3: DONE, 2.4: DONE

ruby_2_4 r59399 merged revision(s) 59033,59034.

----------------------------------------
Bug #13636: REXML::Document.parse_stream doesn't handle when closing tag not provided
https://bugs.ruby-lang.org/issues/13636#change-65886

* Author: fanantoxa (Anton Sivakov)
* Status: Closed
* Priority: Normal
* Assignee: kou (Kouhei Sutou)
* Target version: 2.5
* ruby -v: ruby 2.4.0p0 (2016-12-24 revision 57164) [x86_64-linux]
* Backport: 2.2: WONTFIX, 2.3: DONE, 2.4: DONE
----------------------------------------
I've tried to use REXML for parsing but got unexpected behavior:

Here is example:

~~~ ruby
require 'rexml/document'
require 'rexml/streamlistener'

class Handler include REXML::StreamListener end

xml1 = StringIO.new("<body><item>test</item></body>")
xml2 = StringIO.new("<body><item>test</body>")
xml3 = StringIO.new("<body><item>test</item>")

handler = Handler.new

REXML::Document.parse_stream(xml1, handler) # => nil
REXML::Document.parse_stream(xml2, handler) # => REXML::ParseException: Missing end tag for 'item' (got "body")
REXML::Document.parse_stream(xml3, handler) # => nil
~~~


Actualy XML: "<body><item>test</item>" is broken so it's expected to get:

~~~ ruby
REXML::ParseException.new( "Missing end tag for body")
~~~

I can't rely on REXML parse since I'm not getting exception when XML data structure not valid.





-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>