summaryrefslogtreecommitdiff
path: root/ext/libxml/libxml.c
diff options
context:
space:
mode:
authorShane Caraveo <shane@php.net>2003-10-20 03:11:45 +0000
committerShane Caraveo <shane@php.net>2003-10-20 03:11:45 +0000
commitc55f987230c16971d55225859a411c92dc3f968c (patch)
tree9716569d08defc8e626158797b689ff6b6fa4fa3 /ext/libxml/libxml.c
parent24793840b24a0e3807cb5b52fe9b35480cc2cc78 (diff)
downloadphp-git-c55f987230c16971d55225859a411c92dc3f968c.tar.gz
fix the stat check in stream open
addref to the stream context
Diffstat (limited to 'ext/libxml/libxml.c')
-rw-r--r--ext/libxml/libxml.c23
1 files changed, 20 insertions, 3 deletions
diff --git a/ext/libxml/libxml.c b/ext/libxml/libxml.c
index 984cc2fc81..0f7c4cf272 100644
--- a/ext/libxml/libxml.c
+++ b/ext/libxml/libxml.c
@@ -113,12 +113,24 @@ void *php_libxml_streams_IO_open_wrapper(const char *filename)
int file_exist;
php_stream_statbuf ssbuf;
php_stream_context *context = NULL;
+ php_stream_wrapper *wrapper = NULL;
+ char *path_to_open = 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;
+ path_to_open = resolved_path;
+
+ /* logic copied from _php_stream_stat, but we only want to fail
+ if the wrapper supports stat, otherwise, figure it out from
+ the open. This logic is only to support hiding warnings
+ that the streams layer puts out at times, but for libxml we
+ may try to open files that don't exist, but it is not a failure
+ in xml processing (eg. DTD files) */
+ wrapper = php_stream_locate_url_wrapper(resolved_path, &path_to_open, ENFORCE_SAFE_MODE TSRMLS_CC);
+ if (wrapper && wrapper->wops->url_stat) {
+ if (wrapper->wops->url_stat(wrapper, path_to_open, &ssbuf TSRMLS_CC) == -1) {
+ return NULL;
+ }
}
if (LIBXML(stream_context)) {
@@ -255,6 +267,11 @@ PHP_FUNCTION(libxml_set_streams_context)
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &arg) == FAILURE) {
return;
}
+ if (LIBXML(stream_context)) {
+ ZVAL_DELREF(LIBXML(stream_context));
+ LIBXML(stream_context) = NULL;
+ }
+ ZVAL_ADDREF(arg);
LIBXML(stream_context) = arg;
}
/* }}} */