On Thu, Dec 12, 2002 at 04:43:49PM -0500, Daniel Veillard wrote:
> and provide a patch. Make it checked for Windows paths and verify it
> passes asll libxml2 and libxslt regression tests. Then you issue
> will get fixed promptly if you don't suggest to make silly things
> like changing APIs
I attach a patch that seems to solve the problem without changing any
API, the patch applies cleanly to libxml2 2.5.1.
I attach also the two execution logs of regression tests of libxslt1 and
libxml2, there are some warning that seems to be undocumented (i.e. not
like the absence of 'title.xml' that is previously announced) could you
please have a look at them?
Here is a small log of what I have done:
- removed the URI unescaping of URIs from
xmlParserInputBufferCreateFilename
- added it in xmlFileOpen and xmlGzfileOpen with a fallback on the raw
URI if the function fails with the unescaped URI to preserve the
previous behaviour that do the same but outside the two xml*Open
functions
- left xml*Match function as before because IMHO the URI scheme test has
to be done on the URI before unescaping it (because in turn the
escaping may depend on the URI scheme as in our case: it has to be
considered different if the URI is an HTTP URI or a filename)
- removed the URI escaping from xmlNanoHTTPNewCtxt because now the URI
reach this function untouched
- added the URI unescaping in xmlNanoFTPScanURL with fallback on the raw
URI in case of failure to preserve the previous behaviour
Tell me if the patch may find its way in the CVS or what additional
changes do you like to see in order to accept it.
BTW you have closed the bug reported by me regarding xmlBuildURI, but
remember that the problem isn't really solved, it's only fixed for
absolute URIs, relative ones still suffer of the reported problem.
Cheers.
--
Stefano Zacchiroli - Undergraduate Student of CS @ Uni. Bologna, Italy
zack {cs unibo it,debian.org,bononia.it} - http://www.bononia.it/zack/
" I know you believe you understood what you think I said, but I am not
sure you realize that what you heard is not what I meant! " -- G.Romney
Attachment:
libxml2.regtest.txt.gz
Description: Binary data
diff -ur libxml2-2.5.1/nanoftp.c libxml2-2.5.1-DEBUG/nanoftp.c
--- libxml2-2.5.1/nanoftp.c 2002-12-10 15:56:54.000000000 +0100
+++ libxml2-2.5.1-DEBUG/nanoftp.c 2003-01-10 13:35:39.000000000 +0100
@@ -59,6 +59,7 @@
#include <libxml/xmlmemory.h>
#include <libxml/parser.h>
#include <libxml/xmlerror.h>
+#include <libxml/uri.h>
#include <libxml/nanoftp.h>
#include <libxml/globals.h>
@@ -496,6 +497,7 @@
void*
xmlNanoFTPNewCtxt(const char *URL) {
xmlNanoFTPCtxtPtr ret;
+ char *unescaped;
ret = (xmlNanoFTPCtxtPtr) xmlMalloc(sizeof(xmlNanoFTPCtxt));
if (ret == NULL) return(NULL);
@@ -508,8 +510,12 @@
ret->controlBufUsed = 0;
ret->controlFd = -1;
- if (URL != NULL)
+ unescaped = xmlURIUnescapeString(URL, 0, NULL);
+ if (unescaped != NULL)
+ xmlNanoFTPScanURL(ret, unescaped);
+ else if (URL != NULL)
xmlNanoFTPScanURL(ret, URL);
+ xmlFree(unescaped);
return(ret);
}
diff -ur libxml2-2.5.1/nanohttp.c libxml2-2.5.1-DEBUG/nanohttp.c
--- libxml2-2.5.1/nanohttp.c 2002-12-10 17:21:37.000000000 +0100
+++ libxml2-2.5.1-DEBUG/nanohttp.c 2003-01-10 13:21:41.000000000 +0100
@@ -372,7 +372,6 @@
static xmlNanoHTTPCtxtPtr
xmlNanoHTTPNewCtxt(const char *URL) {
xmlNanoHTTPCtxtPtr ret;
- xmlChar *escaped;
ret = (xmlNanoHTTPCtxtPtr) xmlMalloc(sizeof(xmlNanoHTTPCtxt));
if (ret == NULL) return(NULL);
@@ -383,13 +382,7 @@
ret->fd = -1;
ret->ContentLength = -1;
- escaped = xmlURIEscapeStr(BAD_CAST URL, BAD_CAST"@/:=?;#%&");
- if (escaped != NULL) {
- xmlNanoHTTPScanURL(ret, (const char *) escaped);
- xmlFree(escaped);
- } else {
- xmlNanoHTTPScanURL(ret, URL);
- }
+ xmlNanoHTTPScanURL(ret, URL);
return(ret);
}
diff -ur libxml2-2.5.1/xmlIO.c libxml2-2.5.1-DEBUG/xmlIO.c
--- libxml2-2.5.1/xmlIO.c 2002-12-17 19:28:55.000000000 +0100
+++ libxml2-2.5.1-DEBUG/xmlIO.c 2003-01-10 13:25:26.000000000 +0100
@@ -339,7 +339,7 @@
}
/**
- * xmlFileOpen:
+ * xmlFileOpen_real:
* @filename: the URI for matching
*
* input from FILE *, supports compressed input
@@ -348,7 +348,7 @@
* Returns an I/O context or NULL in case of error
*/
void *
-xmlFileOpen (const char *filename) {
+xmlFileOpen_real (const char *filename) {
const char *path = NULL;
FILE *fd;
@@ -386,6 +386,27 @@
}
/**
+ * xmlFileOpen:
+ * @filename: the URI for matching
+ *
+ * Wrapper around xmlFileOpen_real that try it with an unescaped
+ * version of @filename, if this fails fallback to @filename
+ */
+void *
+xmlFileOpen (const char *filename) {
+ char *unescaped;
+ void *retval;
+ unescaped = xmlURIUnescapeString(filename, 0, NULL);
+ if (unescaped != NULL) {
+ retval = xmlFileOpen_real(unescaped);
+ } else {
+ retval = xmlFileOpen_real(filename);
+ }
+ xmlFree(unescaped);
+ return retval;
+}
+
+/**
* xmlFileOpenW:
* @filename: the URI for matching
*
@@ -513,7 +534,7 @@
}
/**
- * xmlGzfileOpen:
+ * xmlGzfileOpen_real:
* @filename: the URI for matching
*
* input from compressed file open
@@ -522,7 +543,7 @@
* Returns an I/O context or NULL in case of error
*/
static void *
-xmlGzfileOpen (const char *filename) {
+xmlGzfileOpen_real (const char *filename) {
const char *path = NULL;
gzFile fd;
@@ -556,6 +577,27 @@
}
/**
+ * xmlGzfileOpen:
+ * @filename: the URI for matching
+ *
+ * Wrapper around xmlGzfileOpen that try it with an unescaped
+ * version of @filename, if this fails fallback to @filename
+ */
+void *
+xmlGzfileOpen (const char *filename) {
+ char *unescaped;
+ void *retval;
+ unescaped = xmlURIUnescapeString(filename, 0, NULL);
+ if (unescaped != NULL) {
+ retval = xmlGzfileOpen_real(unescaped);
+ } else {
+ retval = xmlGzfileOpen_real(filename);
+ }
+ xmlFree(unescaped);
+ return retval;
+}
+
+/**
* xmlGzfileOpenW:
* @filename: the URI for matching
* @compression: the compression factor (0 - 9 included)
@@ -1724,7 +1766,6 @@
xmlParserInputBufferPtr ret;
int i = 0;
void *context = NULL;
- char *unescaped;
char *normalized;
if (xmlInputCallbackInitialized == 0)
@@ -1740,24 +1781,6 @@
/*
* Try to find one of the input accept method accepting that scheme
* Go in reverse to give precedence to user defined handlers.
- * try with an unescaped version of the URI
- */
- unescaped = xmlURIUnescapeString((char *) normalized, 0, NULL);
- if (unescaped != NULL) {
- for (i = xmlInputCallbackNr - 1;i >= 0;i--) {
- if ((xmlInputCallbackTable[i].matchcallback != NULL) &&
- (xmlInputCallbackTable[i].matchcallback(unescaped) != 0)) {
- context = xmlInputCallbackTable[i].opencallback(unescaped);
- if (context != NULL)
- break;
- }
- }
- xmlFree(unescaped);
- }
-
- /*
- * If this failed try with a non-escaped URI this may be a strange
- * filename
*/
if (context == NULL) {
for (i = xmlInputCallbackNr - 1;i >= 0;i--) {
Attachment:
libxslt1.regtest.txt.gz
Description: Binary data