Project

General

Profile

Actions

Bug #9061

closed

REXML::Parsers::UltraLightParser で doctype を含む XML のパースがうまくいかない

Added by ohai (Ippei Obayashi) about 11 years ago. Updated almost 11 years ago.

Status:
Closed
Target version:
ruby -v:
ruby 2.1.0dev (2013-10-29 trunk 43466) [x86_64-linux]
[ruby-dev:47778]

Description

以下のコード (test_ulp.rb)
require 'rexml/parsers/ultralightparser'
require 'pp'

pp REXML::Parsers::UltraLightParser.new(<<XML).parse

<!ENTITY g "baz">

]>

XML
を動かすと、期待される出力は
[[:xmldecl, "1.0", "UTF-8", nil],
[:text, "\n"],
[:doctype,
[...],
"root",
"SYSTEM",
"foo",
nil,
[:entitydecl, "f", "bar"],
[:entitydecl, "g", "baz"]],
[:text, "\n"],
[:start_element, [...], "root", {}],
[:text, "\n"]]
のようなものですが、実際には
[[:xmldecl, "1.0", "UTF-8", nil],
[:text,
"\n",
[:text, "\n"],
[:start_element, [...], "root", {}],
[:text, "\n"]],
[:start_doctype, "root", "SYSTEM", "foo", nil],
[:entitydecl, "f", "bar"],
[:entitydecl, "g", "baz"]]
のようなものが出力されます。この出力は木構造上の :start_element
や :start_doctype の位置が期待される場所と異なります。
この挙動は ruby 2.1.0dev (2013-10-29 trunk 43466) [x86_64-linux] および
ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-linux] で確認しました。

添付したパッチ(rexml-ultralightparser.patch)のように変更するとうまく動くと思います。


Files

test_ulp.rb (232 Bytes) test_ulp.rb ohai (Ippei Obayashi), 10/30/2013 11:33 PM
rexml-ultralightparser.patch (505 Bytes) rexml-ultralightparser.patch ohai (Ippei Obayashi), 10/30/2013 11:33 PM

Updated by hsbt (Hiroshi SHIBATA) about 11 years ago

  • Assignee set to kou (Kouhei Sutou)
  • Target version set to 2.1.0
Actions #2

Updated by kou (Kouhei Sutou) almost 11 years ago

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

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


  • lib/rexml/parsers/ultralightparser.rb
    (REXML::Parsers::UltraLightParser#parse): Fix wrong :start_doctype
    position.
    [Bug #9061] [ruby-dev:47778]
    Patch by Ippei Obayashi. Thanks!!!

  • test/rexml/parser/test_ultra_light.rb: Add a test for this case.

Updated by kou (Kouhei Sutou) almost 11 years ago

遅くなりましたがテストを追加してパッチをそのまま取り込みました!
報告ありがとうございました!

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0