diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | xmlIO.c | 92 |
2 files changed, 71 insertions, 26 deletions
@@ -1,3 +1,8 @@ +Wed Aug 15 10:46:07 CEST 2001 Daniel Veillard <daniel@veillard.com> + + * xmlIO.c: xmlOutputBufferCreateFilename() didn't unescaped + URIs before doing the lookups (pointed by Mark Vakoc) + Tue Aug 14 18:37:23 CEST 2001 Daniel Veillard <daniel@veillard.com> * xpath.c: serious changes on Result Value Trees and NodeSets @@ -1663,8 +1663,9 @@ xmlOutputBufferCreateFilename(const char *URI, xmlCharEncodingHandlerPtr encoder, int compression) { xmlOutputBufferPtr ret; - int i; + int i = 0; void *context = NULL; + char *unescaped; int is_http_uri = 0; /* Can't change if HTTP disabled */ @@ -1679,40 +1680,79 @@ xmlOutputBufferCreateFilename(const char *URI, is_http_uri = xmlIOHTTPMatch( URI ); #endif + + /* + * Try to find one of the output accept method accepting taht scheme + * Go in reverse to give precedence to user defined handlers. + * try with an unescaped version of the URI + */ + unescaped = xmlURIUnescapeString(URI, 0, NULL); + if (unescaped != NULL) { #ifdef HAVE_ZLIB_H - if ((compression > 0) && (compression <= 9) && (is_http_uri == 0)) { - context = xmlGzfileOpenW(URI, compression); - if (context != NULL) { - ret = xmlAllocOutputBuffer(encoder); - if (ret != NULL) { - ret->context = context; - ret->writecallback = xmlGzfileWrite; - ret->closecallback = xmlGzfileClose; + if ((compression > 0) && (compression <= 9) && (is_http_uri == 0)) { + context = xmlGzfileOpenW(unescaped, compression); + if (context != NULL) { + ret = xmlAllocOutputBuffer(encoder); + if (ret != NULL) { + ret->context = context; + ret->writecallback = xmlGzfileWrite; + ret->closecallback = xmlGzfileClose; + } + xmlFree(unescaped); + return(ret); } - return(ret); } - } #endif + for (i = xmlOutputCallbackNr - 1;i >= 0;i--) { + if ((xmlOutputCallbackTable[i].matchcallback != NULL) && + (xmlOutputCallbackTable[i].matchcallback(unescaped) != 0)) { +#if defined(LIBXML_HTTP_ENABLED) && defined(HAVE_ZLIB_H) + /* Need to pass compression parameter into HTTP open calls */ + if (xmlOutputCallbackTable[i].matchcallback == xmlIOHTTPMatch) + context = xmlIOHTTPOpenW(unescaped, compression); + else +#endif + context = xmlOutputCallbackTable[i].opencallback(unescaped); + if (context != NULL) + break; + } + } + xmlFree(unescaped); + } /* - * Try to find one of the output accept method accepting that scheme - * Go in reverse to give precedence to user defined handlers. + * If this failed try with a non-escaped URI this may be a strange + * filename */ - for (i = xmlOutputCallbackNr - 1;i >= 0;i--) { - if ((xmlOutputCallbackTable[i].matchcallback != NULL) && - (xmlOutputCallbackTable[i].matchcallback(URI) != 0)) { - -#if ( defined( LIBXML_HTTP_ENABLED ) && defined( HAVE_ZLIB_H ) ) - /* Need to pass compression parameter into HTTP open calls */ - - if ( xmlOutputCallbackTable[i].matchcallback == xmlIOHTTPMatch ) - context = xmlIOHTTPOpenW( URI, compression ); - else + if (context == NULL) { +#ifdef HAVE_ZLIB_H + if ((compression > 0) && (compression <= 9) && (is_http_uri == 0)) { + context = xmlGzfileOpenW(URI, compression); + if (context != NULL) { + ret = xmlAllocOutputBuffer(encoder); + if (ret != NULL) { + ret->context = context; + ret->writecallback = xmlGzfileWrite; + ret->closecallback = xmlGzfileClose; + } + return(ret); + } + } #endif + for (i = xmlOutputCallbackNr - 1;i >= 0;i--) { + if ((xmlOutputCallbackTable[i].matchcallback != NULL) && + (xmlOutputCallbackTable[i].matchcallback(URI) != 0)) { context = xmlOutputCallbackTable[i].opencallback(URI); - - if (context != NULL) - break; +#if defined(LIBXML_HTTP_ENABLED) && defined(HAVE_ZLIB_H) + /* Need to pass compression parameter into HTTP open calls */ + if (xmlOutputCallbackTable[i].matchcallback == xmlIOHTTPMatch) + context = xmlIOHTTPOpenW(URI, compression); + else +#endif + context = xmlOutputCallbackTable[i].opencallback(URI); + if (context != NULL) + break; + } } } |