Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions ext/phar/tests/stream_resolve_include_path.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
--TEST--
Using stream_resolve_include_path() on phar://
--INI--
phar.readonly=0
--FILE--
<?php

$file = __DIR__ . '/stream_resolve_include_path.phar';
$path = 'phar://' . $file . '/file.php';
file_put_contents($path, 'Test');
var_dump(stream_resolve_include_path($path) === $path);
unlink($file);

?>
--EXPECT--
bool(true)
7 changes: 5 additions & 2 deletions main/fopen_wrappers.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 == '.' &&
Expand Down