After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 337483 - xmllint do network connections with --nonet
xmllint do network connections with --nonet
Status: RESOLVED FIXED
Product: libxml2
Classification: Platform
Component: general
2.6.x
Other All
: Normal normal
: ---
Assigned To: Daniel Veillard
libxml QA maintainers
Depends on:
Blocks:
 
 
Reported: 2006-04-06 11:54 UTC by vyt
Modified: 2015-06-23 16:20 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Change the default external entity loader if --nonet is passed to xmllint (539 bytes, patch)
2006-04-16 01:11 UTC, Gary Coady
committed Details | Review

Description vyt 2006-04-06 11:54:01 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:
Comment 1 Gary Coady 2006-04-16 01:10:51 UTC
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.
Comment 2 Gary Coady 2006-04-16 01:11:59 UTC
Created attachment 63616 [details] [review]
Change the default external entity loader if --nonet is passed to xmllint
Comment 3 Daniel Veillard 2006-04-25 16:18:25 UTC
Okay, that's a bit what I wanted to avoid, but with the given evidence
the patch is fine,

  applied and commited,

  thanks !

Daniel

  
Comment 4 Pascal Wittmann 2015-06-23 16:20:04 UTC
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