diff options
author | Daniel Veillard <veillard@src.gnome.org> | 2001-08-15 08:47:42 +0000 |
---|---|---|
committer | Daniel Veillard <veillard@src.gnome.org> | 2001-08-15 08:47:42 +0000 |
commit | ecb6f5bda5f319efe726165833b33b953a09f4a5 (patch) | |
tree | b73cf5e34005b202a010075a59e903420eaaf0ca /xmlIO.c | |
parent | 0ab5caba5b47a2cdafa83059ec3e02fde78d6262 (diff) | |
download | android_external_libxml2-ecb6f5bda5f319efe726165833b33b953a09f4a5.tar.gz android_external_libxml2-ecb6f5bda5f319efe726165833b33b953a09f4a5.tar.bz2 android_external_libxml2-ecb6f5bda5f319efe726165833b33b953a09f4a5.zip |
xmlOutputBufferCreateFilename() didn't unescaped URIs before doing the
* xmlIO.c: xmlOutputBufferCreateFilename() didn't unescaped
URIs before doing the lookups (pointed by Mark Vakoc)
Daniel
Diffstat (limited to 'xmlIO.c')
-rw-r--r-- | xmlIO.c | 92 |
1 files changed, 66 insertions, 26 deletions
@@ -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; + } } } |