Project

General

Profile

Actions

Bug #13636

closed

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

Added by fanantoxa (Anton Sivakov) almost 7 years ago. Updated over 6 years ago.

Status:
Closed
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) almost 7 years ago

Expected to get exception for xml3 example

Updated by hsbt (Hiroshi SHIBATA) almost 7 years ago

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

Updated by kou (Kouhei Sutou) almost 7 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) almost 7 years ago

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

Actions #5

Updated by usa (Usaku NAKAMURA) almost 7 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) almost 7 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) over 6 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.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0