Index: libxml.c =================================================================== RCS file: /repository/php-src/ext/libxml/libxml.c,v retrieving revision 1.31 diff -u -r1.31 libxml.c --- libxml.c 28 Feb 2005 08:16:47 -0000 1.31 +++ libxml.c 7 Aug 2005 13:24:13 -0000 @@ -253,14 +253,26 @@ int php_libxml_streams_IO_match_wrapper(const char *filename) { char *resolved_path; - int retval; + int retval, isescaped=0; + xmlURI *uri; TSRMLS_FETCH(); if (zend_is_executing(TSRMLS_C)) { - resolved_path = xmlURIUnescapeString(filename, 0, NULL); + uri = xmlParseURI((xmlChar *)filename); + if (uri && (uri->scheme == NULL || (xmlStrncmp(uri->scheme, "file", 4) == 0))) { + resolved_path = xmlURIUnescapeString(filename, 0, NULL); + isescaped = 1; + } else { + resolved_path = (char *)filename; + } + + if (uri) { + xmlFreeURI(uri); + } + retval = php_stream_locate_url_wrapper(resolved_path, NULL, 0 TSRMLS_CC) ? 1 : 0; - if (resolved_path) { + if (resolved_path && isescaped) { xmlFree(resolved_path); } return retval; @@ -275,9 +287,22 @@ php_stream_wrapper *wrapper = NULL; char *resolved_path, *path_to_open = NULL; void *ret_val = NULL; + int isescaped=0; + xmlURI *uri; TSRMLS_FETCH(); - resolved_path = xmlURIUnescapeString(filename, 0, NULL); + + uri = xmlParseURI((xmlChar *)filename); + if (uri && (uri->scheme == NULL || (xmlStrncmp(uri->scheme, "file", 4) == 0))) { + resolved_path = xmlURIUnescapeString(filename, 0, NULL); + isescaped = 1; + } else { + resolved_path = (char *)filename; + } + + if (uri) { + xmlFreeURI(uri); + } if (resolved_path == NULL) { return NULL; @@ -302,7 +327,9 @@ } ret_val = php_stream_open_wrapper_ex(path_to_open, (char *)mode, ENFORCE_SAFE_MODE|REPORT_ERRORS, NULL, context); - xmlFree(resolved_path); + if (isescaped) { + xmlFree(resolved_path); + } return ret_val; }