GNOME Bugzilla – Bug 337483
xmllint do network connections with --nonet
Last modified: 2015-06-23 16:20:04 UTC
Please describe the problem: xmllint ignores '--nonet' if '--postvalid' added. Steps to reproduce: $ export XML_CATALOG_FILES=non_existent_file $ xmllint --noout --nonet --postvalid test.xml test.xml: <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd"> <article> <title>test</title> <section> <title>test</title> <para> test </para> </section> </article> Reproduced on: 1. $ xmllint --version xmllint: using libxml version 20623 compiled with: Threads Tree Output Push Reader Patterns Writer SAXv1 FTP HTTP DTDValid HTML Legacy C14N Catalog XPath XPointer XInclude Iconv ISO8859X Unicode Regexps Automata Expr Schemas Schematron Modules Debug (ALT Linux, kernel 2.6.14-std26-up-alt5) 2. xmllint: using libxml version 20623 compiled with: Tree Output Push Reader Patterns Writer SAXv1 FTP HTTP DTDValid HTML Legacy C14N Catalog XPath XPointer XInclude Iconv ISO8859X Unicode Regexps Automata Expr Schemas Schematron Modules Debug (FreeBSD 6.0-RELEASE-p6) 3. xmllint: using libxml version 20616 compiled with: DTDValid HTTP HTML C14N Catalog XPath XPointer XInclude Iconv Unicode Regexps Automata Schemas (Linux Mandrake release 7.2 (Odyssey) for i586, kernel 2.4.33-pre1 SMP) 4. xmllint: using libxml version 20614 compiled with: DTDValid FTP HTTP HTML C14N Catalog XPath XPointer XInclude Iconv Unicode Regexps Automata Schemas (Fedora Core 3, kernel 2.6.9-1.667) Actual results: xmllint print warnings: I/O error : Attempt to load network entity but connected to 105.168.202.209 (pan.oasis-open.org) and download DocBook DTD Expected results: No network activity as described in 'man xmllint': --nonet Do not use the Internet to fetch DTD's or entities. Does this happen every time? Yes. Other information:
This bug was also reported at https://launchpad.net/distros/ubuntu/+source/libxml2/+bug/17984 The problem is that there is no way to provide options to xmlSAXParseDTD, so xmlParseDTD always ends up using the default external entity loader. There is a proposed workaround for xmllint, where if --nonet is passed as a parameter, then the default external entity loader is changed to xmlNoNetExternalEntityLoader.
Created attachment 63616 [details] [review] Change the default external entity loader if --nonet is passed to xmllint
Okay, that's a bit what I wanted to avoid, but with the given evidence the patch is fine, applied and commited, thanks ! Daniel
There seems to be a regression. Following the steps mentioned above I can reproduce the bug with % xmllint --version xmllint: using libxml version 20902 compiled with: Threads Tree Output Push Reader Patterns Writer SAXv1 FTP HTTP DTDValid HTML Legacy C14N Catalog XPath XPointer XInclude Iconv ISO8859X Unicode Regexps Automata Expr Schemas Schematron Modules Debug Zlib Lzma This is on NixOS. The actual error is: % xmllint --noout --nonet --postvalid test.xml I/O error : Attempt to load network entity http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd test.xml:3: warning: failed to load external entity "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd" "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd"> ^ I/O error : Attempt to load network entity http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd warning: failed to load external entity "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd" validity error : Could not load the external subset "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd" Document test.xml does not validate