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 500664 - DTD validation of XML files starting with // doesn't work
DTD validation of XML files starting with // doesn't work
Status: RESOLVED FIXED
Product: libxml2
Classification: Platform
Component: general
2.6.30
Other All
: Normal normal
: ---
Assigned To: Daniel Veillard
libxml QA maintainers
Depends on:
Blocks:
 
 
Reported: 2007-11-30 15:34 UTC by Petr Sumbera
Modified: 2008-02-07 10:18 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Petr Sumbera 2007-11-30 15:34:51 UTC
Please describe the problem:
E.g. following command will fail:

xmllint //foo/bar.xml   # where DTD specified in XML file is: /foo2/bar.dtd 

because it's trying to load DTD file from wrong location: /foo/foo2/bar.dtd

The same problem happens also during usual using of libxml2 (not just with xmllint).

This issue was already discussed:

http://mail.gnome.org/archives/xml/2007-November/thread.html#00014

Steps to reproduce:


Actual results:


Expected results:


Does this happen every time?
yes

Other information:
Following patch solves this:

--- libxml2-2.6.30/uri.c.orig   Tue Nov 20 01:44:59 2007
+++ libxml2-2.6.30/uri.c        Tue Nov 20 01:45:29 2007
@@ -2418,6 +2418,12 @@

     if (path == NULL)
        return(NULL);
+
+    /* sanitize filename starting with // so it can be used as URI */
+    if (strlen(path) > 2 && path[0]=='/'
+        && path[1]=='/' && path[2]!='/')
+       path++;
+
     if ((uri = xmlParseURI((const char *) path)) != NULL) {
        xmlFreeURI(uri);
        return xmlStrdup(path);
Comment 1 Daniel Veillard 2007-11-30 17:10:30 UTC
whoops I have been avoiding some part of my libxml email folder
in the last weeks and I missed the 2 followups.

I don't think you need to call strlen(),
if  path[0]=='/' && path[1]=='/'
then it's at least of lenght 2 
that won't match (and won't fail) if lenght 0 or 1.

Now what is so special with "//" and "///" ?

Daniel
Comment 2 Petr Sumbera 2007-11-30 18:05:46 UTC
>I don't think you need to call strlen(),
>if  path[0]=='/' && path[1]=='/'
>then it's at least of lenght 2 
>that won't match (and won't fail) if lenght 0 or 1.

Uff, yes you are right :-)

>Now what is so special with "//" and "///" ?

Basically there are some silly scripts which works like this:

FILE=/foo/xml
ROOT=/ or ROOT=/my_root
/bin/myxmlapp $ROOT/$FILE
Comment 3 Daniel Veillard 2008-02-07 10:18:30 UTC
Okay, patch applied to SVN, and commited,

  thanks !

Daniel