Bug #8844

Nested ParseError in rexml

Added by Ippei Obayashi 8 months ago. Updated 8 months ago.

[ruby-dev:47672]
Status:Closed
Priority:Normal
Assignee:Kouhei Sutou
Category:lib
Target version:-
ruby -v:ruby 2.1.0dev (2013-08-31 trunk 42735) [x86_64-linux] Backport:1.9.3: UNKNOWN, 2.0.0: UNKNOWN

Description

以下のように不正なXMLをパースすると
require 'rexml/document'
REXML::Document.new("foo")
例外が発生し、以下のようなメッセージが表示されます(完全なものは添付したparseerror.txt)。
/home/ohai/.rbenv/versions/trunk-modified/lib/ruby/2.1.0/rexml/parsers/treeparser.rb:95:
in `rescue in parse': #<REXML::ParseException: Missing end tag for 'a' (got "b") (REXML:
:ParseException)
Line: 1
Position: 10
Last 80 unconsumed characters:

 :

nested_parseerror.rb:3:in `'
...
Missing end tag for 'a' (got "b")
Line: 1
Position: 10
Last 80 unconsumed characters:

Line: 1
Position: 10
Last 80 unconsumed characters:
:
同じ情報が何度も表示され、冗長です。

添付したパッチのように変更すればこの繰り返しはなくなるのですがどうでしょうか。

parseerror.txt Magnifier (1.29 KB) Ippei Obayashi, 08/31/2013 01:29 PM

rexml-nested-parseerror.diff Magnifier (1.01 KB) Ippei Obayashi, 08/31/2013 01:29 PM

Associated revisions

Revision 42813
Added by Kouhei Sutou 8 months ago

  • lib/rexml/parsers/treeparser.rb (REXML::Parsers::TreeParser#parse): Remove needless nested parse exception information. [Bug #8844] Reported by Ippei Obayashi. Thanks!!!
  • test/rexml/parser/test_tree.rb: Add a test for the above case.

Revision 42815
Added by Kouhei Sutou 8 months ago

  • lib/rexml/parsers/treeparser.rb (REXML::Parsers::TreeParser#parse): Add source information to parse exception on no close tag error. [Bug #8844] Patch by Ippei Obayashi. Thanks!!!
  • test/rexml/parser/test_tree.rb: Add a test for the above case.

History

#1 Updated by Kouhei Sutou 8 months ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

This issue was solved with changeset r42813.
Ippei, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


  • lib/rexml/parsers/treeparser.rb (REXML::Parsers::TreeParser#parse): Remove needless nested parse exception information. [Bug #8844] Reported by Ippei Obayashi. Thanks!!!
  • test/rexml/parser/test_tree.rb: Add a test for the above case.

#2 Updated by Kouhei Sutou 8 months ago

  • Assignee set to Kouhei Sutou

ありがとうございます!
取り込みました!

パッチには別の問題の修正もあったのでそっちも取り込みました。

Also available in: Atom PDF