Project

General

Profile

Bug #13636

REXML::Document.parse_stream doesn't handle when closing tag not provided

Added by fanantoxa (Anton Sivakov) about 3 years ago. Updated almost 3 years ago.

Status:
Closed
Priority:
Normal
Target version:
ruby -v:
ruby 2.4.0p0 (2016-12-24 revision 57164) [x86_64-linux]
[ruby-core:81593]

Description

I've tried to use REXML for parsing but got unexpected behavior:

Here is example:

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: "test" is broken so it's expected to get:

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.

Updated by fanantoxa (Anton Sivakov) about 3 years ago

Expected to get exception for xml3 example

Updated by hsbt (Hiroshi SHIBATA) about 3 years ago

  • Target version set to 2.5
  • Assignee set to kou (Kouhei Sutou)
  • Status changed from Open to Assigned
#3

Updated by kou (Kouhei Sutou) about 3 years ago

  • Status changed from Assigned to Closed

Applied in changeset trunk|r59033.


rexml: add close tag check on end of document to StreamParser

[ruby-core:81593] [Bug #13636]

Reported by Anton Sivakov. Thanks!!!

Updated by kou (Kouhei Sutou) about 3 years ago

Thanks for your report.
I've added a validation on end of document.

#5

Updated by usa (Usaku NAKAMURA) about 3 years ago

  • Backport changed from 2.2: UNKNOWN, 2.3: UNKNOWN, 2.4: UNKNOWN to 2.2: WONTFIX, 2.3: REQUIRED, 2.4: REQUIRED

Updated by usa (Usaku NAKAMURA) about 3 years ago

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

ruby_2_3 r59239 merged revision(s) 59033,59034.

Updated by nagachika (Tomoyuki Chikanaga) almost 3 years ago

  • 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.

Also available in: Atom PDF