GNOME Bugzilla – Bug 500664
DTD validation of XML files starting with // doesn't work
Last modified: 2008-02-07 10:18:30 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);
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
>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
Okay, patch applied to SVN, and commited, thanks ! Daniel