Hi Paul,

Even if XML::Parser.default_load_external_dtd is set to false the parser loads the DTD, see test script:

Upgrade to the latest libxml version (0.7.0) - it works fine here. I've added your test case to tests/tc_xml_dtd.rb (in SVN, but not in the 0.7.0 release).

  def test_external_dtd
    xml = <<-EOS
      <!DOCTYPE test PUBLIC "-//TEST" "test.dtd" []>
      <test>
        <title>T1</title>
      </test>
    EOS

    messages = Array.new
    XML::Parser.register_error_handler(lambda { |msg| messages << msg })

    XML::Parser.default_load_external_dtd = false
    doc = XML::Parser.string(xml).parse
    assert_equal(Array.new, messages)

    XML::Parser.default_load_external_dtd = true
    doc = XML::Parser.string(xml).parse
assert_equal('I/O warning : failed to load external entity "test.dtd" <!DOCTYPE test PUBLIC "-//TEST" "test.dtd" []> ^',
                 messages.map{|msg| msg.strip}.join(' '))
  end

I can suppress the warnings with default_warnings=false but this is not the issue, the parser still attempts to load the DTD. In the case above the DTD does not exist so no harm is done. In another test case I have the DTD does exist but should not be loaded, in this case the bug makes it impossible to work with the XML.

Upgrade, and see if the problem disappears.

Charlie

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

_______________________________________________
libxml-devel mailing list
libxml-devel@rubyforge.org
http://rubyforge.org/mailman/listinfo/libxml-devel

Reply via email to