Project

General

Profile

Bug #13636

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

Added by fanantoxa (Anton Sivakov) over 2 years ago. Updated over 2 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.

Associated revisions

Revision d311921d
Added by kou (Kouhei Sutou) over 2 years ago

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

Revision 59033
Added by kou (Kouhei Sutou) over 2 years ago

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

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

Reported by Anton Sivakov. Thanks!!!

Revision 59033
Added by kou (Kouhei Sutou) over 2 years ago

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

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

Reported by Anton Sivakov. Thanks!!!

Revision 59033
Added by kou (Kouhei Sutou) over 2 years ago

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

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

Reported by Anton Sivakov. Thanks!!!

Revision 59034
Added by svn over 2 years ago

  • properties.

Revision 971b99f3
Added by usa (Usaku NAKAMURA) over 2 years ago

merge revision(s) 59033,59034: [Backport #13636]

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

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

    Reported by Anton Sivakov. Thanks!!!

    * properties.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_3@59239 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 59239
Added by usa (Usaku NAKAMURA) over 2 years ago

merge revision(s) 59033,59034: [Backport #13636]

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

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

Reported by Anton Sivakov. Thanks!!!

* properties.

Revision 3fd2cbec
Added by nagachika (Tomoyuki Chikanaga) over 2 years ago

merge revision(s) 59033,59034: [Backport #13636]

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

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

    Reported by Anton Sivakov. Thanks!!!

    * properties.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_4@59399 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 59399
Added by nagachika (Tomoyuki Chikanaga) over 2 years ago

merge revision(s) 59033,59034: [Backport #13636]

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

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

Reported by Anton Sivakov. Thanks!!!

* properties.

History

Updated by fanantoxa (Anton Sivakov) over 2 years ago

Expected to get exception for xml3 example

Updated by hsbt (Hiroshi SHIBATA) over 2 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) over 2 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) over 2 years ago

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

#5

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