[libxml-devel] DTD's still loaded when default_load_external_dtd is false
Charlie Savage
cfis at savagexi.com
Thu Jul 10 02:53:01 EDT 2008
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3237 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://rubyforge.org/pipermail/libxml-devel/attachments/20080710/fe24dfcc/attachment.bin>
More information about the libxml-devel
mailing list