summaryrefslogtreecommitdiff
path: root/ext/libxml/libxml.c
diff options
context:
space:
mode:
authorRob Richards <rrichards@php.net>2003-10-19 23:25:48 +0000
committerRob Richards <rrichards@php.net>2003-10-19 23:25:48 +0000
commit33004a01eeb3f65ab65cdb67fe0dbad8e83f5d8d (patch)
tree25a524d373d96d11bc69c8207c289349901b9193 /ext/libxml/libxml.c
parent052f9378b2cc5a3fffc3c7caad7a1df8a48ecd15 (diff)
downloadphp-git-33004a01eeb3f65ab65cdb67fe0dbad8e83f5d8d.tar.gz
unescape filepath which libxml excapes
Diffstat (limited to 'ext/libxml/libxml.c')
-rw-r--r--ext/libxml/libxml.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/ext/libxml/libxml.c b/ext/libxml/libxml.c
index 9957f3e411..480680e21a 100644
--- a/ext/libxml/libxml.c
+++ b/ext/libxml/libxml.c
@@ -109,13 +109,23 @@ int php_libxml_streams_IO_match_wrapper(const char *filename)
void *php_libxml_streams_IO_open_wrapper(const char *filename)
{
+ char resolved_path[MAXPATHLEN + 1];
+ int file_exist;
+ php_stream_statbuf ssbuf;
php_stream_context *context = NULL;
+
TSRMLS_FETCH();
+ xmlURIUnescapeString(filename, 0, resolved_path);
+ file_exist = _php_stream_stat_path((char *) resolved_path, &ssbuf TSRMLS_CC);
+ if (file_exist == -1) {
+ return NULL;
+ }
+
if (LIBXML(stream_context)) {
context = zend_fetch_resource(&LIBXML(stream_context) TSRMLS_CC, -1, "Stream-Context", NULL, 1, php_le_stream_context());
- return php_stream_open_wrapper_ex((char *)filename, "rb", ENFORCE_SAFE_MODE|REPORT_ERRORS, NULL, context);
+ return php_stream_open_wrapper_ex((char *)resolved_path, "rb", ENFORCE_SAFE_MODE|REPORT_ERRORS, NULL, context);
}
- return php_stream_open_wrapper((char *)filename, "rb", ENFORCE_SAFE_MODE|REPORT_ERRORS, NULL);
+ return php_stream_open_wrapper((char *)resolved_path, "rb", ENFORCE_SAFE_MODE|REPORT_ERRORS, NULL);
}
int php_libxml_streams_IO_read(void *context, char *buffer, int len)