From 445147505482f3ad30832570c3ce73f15df48a74 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Thu, 18 Jul 2019 14:18:49 +0200 Subject: [PATCH] Support stream wrappers in stream_resolve_include_path() --- ext/phar/tests/stream_resolve_include_path.phpt | 16 ++++++++++++++++ main/fopen_wrappers.c | 7 +++++-- 2 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 ext/phar/tests/stream_resolve_include_path.phpt diff --git a/ext/phar/tests/stream_resolve_include_path.phpt b/ext/phar/tests/stream_resolve_include_path.phpt new file mode 100644 index 0000000000000..58d94ab8cfe70 --- /dev/null +++ b/ext/phar/tests/stream_resolve_include_path.phpt @@ -0,0 +1,16 @@ +--TEST-- +Using stream_resolve_include_path() on phar:// +--INI-- +phar.readonly=0 +--FILE-- + +--EXPECT-- +bool(true) diff --git a/main/fopen_wrappers.c b/main/fopen_wrappers.c index b0bfa4feda8f9..7526894993a09 100644 --- a/main/fopen_wrappers.c +++ b/main/fopen_wrappers.c @@ -483,16 +483,19 @@ PHPAPI zend_string *php_resolve_path(const char *filename, size_t filename_lengt return NULL; } - /* Don't resolve paths which contain protocol (except of file://) */ + /* Stream wrappers do not resolve against the include path. */ for (p = filename; isalnum((int)*p) || *p == '+' || *p == '-' || *p == '.'; p++); if ((*p == ':') && (p - filename > 1) && (p[1] == '/') && (p[2] == '/')) { wrapper = php_stream_locate_url_wrapper(filename, &actual_path, STREAM_OPEN_FOR_INCLUDE); + if (!wrapper) { + return NULL; + } if (wrapper == &php_plain_files_wrapper) { if (tsrm_realpath(actual_path, resolved_path)) { return zend_string_init(resolved_path, strlen(resolved_path), 0); } } - return NULL; + return zend_string_init(actual_path, strlen(actual_path), 0); } if ((*filename == '.' &&