diff --git a/ChangeLog b/ChangeLog index bc1b20ef..1ceb5f69 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Sun Jul 8 20:34:35 CEST 2001 Daniel Veillard + + * xmlIO.c: fixed an old bug raised by Bernhard Zwisch, the I/O + layer should URI-Unescape before trying to open resources. + Sun Jul 8 16:26:00 CEST 2001 Daniel Veillard * xpath.c: fix the name() bug for elements in the default diff --git a/xmlIO.c b/xmlIO.c index fd2b6104..2922932f 100644 --- a/xmlIO.c +++ b/xmlIO.c @@ -62,6 +62,7 @@ #include #include #include +#include #include #include #include @@ -883,8 +884,9 @@ xmlParserInputBufferCreateFilename #endif (const char *URI, xmlCharEncoding enc) { xmlParserInputBufferPtr ret; - int i; + int i = 0; void *context = NULL; + char *unescaped; if (xmlInputCallbackInitialized == 0) xmlRegisterDefaultInputCallbacks(); @@ -894,13 +896,33 @@ xmlParserInputBufferCreateFilename /* * Try to find one of the input accept method accepting taht scheme * Go in reverse to give precedence to user defined handlers. + * try with an unescaped version of the URI */ - for (i = xmlInputCallbackNr - 1;i >= 0;i--) { - if ((xmlInputCallbackTable[i].matchcallback != NULL) && - (xmlInputCallbackTable[i].matchcallback(URI) != 0)) { - context = xmlInputCallbackTable[i].opencallback(URI); - if (context != NULL) - break; + unescaped = xmlURIUnescapeString(URI, 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--) { + if ((xmlInputCallbackTable[i].matchcallback != NULL) && + (xmlInputCallbackTable[i].matchcallback(URI) != 0)) { + context = xmlInputCallbackTable[i].opencallback(URI); + if (context != NULL) + break; + } } } if (context == NULL) {