diff --git a/phpBB/common.php b/phpBB/common.php index 46098ff44c..7ace4cf12a 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -65,7 +65,7 @@ if (!defined('PHPBB_INSTALLED')) // Eliminate . and .. from the path require($phpbb_root_path . 'phpbb/filesystem.' . $phpEx); - $script_path = \phpbb\storage\helper::clean_path($script_path); + $script_path = \phpbb\filesystem\helper::clean_path($script_path); $url = (($secure) ? 'https://' : 'http://') . $server_name; diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index adfe3c01a2..5bf86276c8 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -3479,7 +3479,7 @@ function phpbb_filter_root_path($errfile) if (empty($root_path)) { - $root_path = \phpbb\storage\helper::realpath(dirname(__FILE__) . '/../'); + $root_path = \phpbb\filesystem\helper::realpath(dirname(__FILE__) . '/../'); } return str_replace(array($root_path, '\\'), array('[ROOT]', '/'), $errfile); diff --git a/phpBB/includes/functions_compatibility.php b/phpBB/includes/functions_compatibility.php index 9bf052f479..e1ff4004ff 100644 --- a/phpBB/includes/functions_compatibility.php +++ b/phpBB/includes/functions_compatibility.php @@ -96,12 +96,12 @@ function phpbb_check_hash($password, $hash) */ function phpbb_clean_path($path) { - if (!class_exists('\phpbb\storage\helper')) + if (!class_exists('\phpbb\filesystem\helper')) { - require($phpbb_root_path . 'phpbb/storage/helper.' . $phpEx); + require($phpbb_root_path . 'phpbb/filesystem/helper.' . $phpEx); } - return \phpbb\storage\helper::clean_path($path); + return \phpbb\filesystem\helper::clean_path($path); } /** @@ -439,31 +439,31 @@ function phpbb_is_writable($file) * @param string $path Path to check absoluteness of * @return boolean * - * @deprecated 3.2.0-dev use \phpbb\storage\helper::is_absolute_path() instead + * @deprecated 3.2.0-dev use \phpbb\filesystem\helper::is_absolute_path() instead */ function phpbb_is_absolute($path) { - if (!class_exists('\phpbb\storage\helper')) + if (!class_exists('\phpbb\filesystem\helper')) { - require($phpbb_root_path . 'phpbb/storage/helper.' . $phpEx); + require($phpbb_root_path . 'phpbb/filesystem/helper.' . $phpEx); } - return \phpbb\storage\helper::is_absolute_path($path); + return \phpbb\filesystem\helper::is_absolute_path($path); } /** * A wrapper for realpath * - * @deprecated 3.2.0-dev use \phpbb\storage\helper::realpath() instead + * @deprecated 3.2.0-dev use \phpbb\filesystem\helper::realpath() instead */ function phpbb_realpath($path) { - if (!class_exists('\phpbb\storage\helper')) + if (!class_exists('\phpbb\filesystem\helper')) { - require($phpbb_root_path . 'phpbb/storage/helper.' . $phpEx); + require($phpbb_root_path . 'phpbb/filesystem/helper.' . $phpEx); } - return \phpbb\storage\helper::realpath($path); + return \phpbb\filesystem\helper::realpath($path); } /** diff --git a/phpBB/phpbb/composer/installer.php b/phpBB/phpbb/composer/installer.php index 6bab30eb9e..e96a39c4b8 100644 --- a/phpBB/phpbb/composer/installer.php +++ b/phpBB/phpbb/composer/installer.php @@ -108,7 +108,7 @@ class installer $this->root_path = $root_path; $this->request = $request; - putenv('COMPOSER_HOME=' . \phpbb\storage\helper::realpath($root_path) . '/store/composer'); + putenv('COMPOSER_HOME=' . \phpbb\filesystem\helper::realpath($root_path) . '/store/composer'); } /** diff --git a/phpBB/phpbb/di/container_builder.php b/phpBB/phpbb/di/container_builder.php index 47a858d605..307f03f072 100644 --- a/phpBB/phpbb/di/container_builder.php +++ b/phpBB/phpbb/di/container_builder.php @@ -179,7 +179,7 @@ class container_builder $this->register_ext_compiler_pass(); } - $loader = new YamlFileLoader($this->container, new FileLocator(\phpbb\storage\helper::realpath($this->get_config_path()))); + $loader = new YamlFileLoader($this->container, new FileLocator(\phpbb\filesystem\helper::realpath($this->get_config_path()))); $loader->load($this->container->getParameter('core.environment') . '/config.yml'); $this->inject_custom_parameters(); diff --git a/phpBB/phpbb/di/extension/core.php b/phpBB/phpbb/di/extension/core.php index 84148eced3..e3c9967b7b 100644 --- a/phpBB/phpbb/di/extension/core.php +++ b/phpBB/phpbb/di/extension/core.php @@ -53,7 +53,7 @@ class core extends Extension */ public function load(array $configs, ContainerBuilder $container) { - $loader = new YamlFileLoader($container, new FileLocator(\phpbb\storage\helper::realpath($this->config_path))); + $loader = new YamlFileLoader($container, new FileLocator(\phpbb\filesystem\helper::realpath($this->config_path))); $loader->load($container->getParameter('core.environment') . '/container/environment.yml'); $config = $this->getConfiguration($configs, $container); diff --git a/phpBB/phpbb/extension/di/extension_base.php b/phpBB/phpbb/extension/di/extension_base.php index e6fd5688cc..a8f8ca0776 100644 --- a/phpBB/phpbb/extension/di/extension_base.php +++ b/phpBB/phpbb/extension/di/extension_base.php @@ -94,7 +94,7 @@ class extension_base extends Extension if ($services_directory && $services_file) { - $loader = new YamlFileLoader($container, new FileLocator(\phpbb\storage\helper::realpath($services_directory))); + $loader = new YamlFileLoader($container, new FileLocator(\phpbb\filesystem\helper::realpath($services_directory))); $loader->load($services_file); } } diff --git a/phpBB/phpbb/filesystem/filesystem.php b/phpBB/phpbb/filesystem/filesystem.php index 30a16bc756..01e0bb2cb2 100644 --- a/phpBB/phpbb/filesystem/filesystem.php +++ b/phpBB/phpbb/filesystem/filesystem.php @@ -162,7 +162,7 @@ class filesystem implements filesystem_interface */ public function clean_path($path) { - return \phpbb\storage\helper::clean_path($path); + return \phpbb\filesystem\helper::clean_path($path); } /** @@ -208,7 +208,7 @@ class filesystem implements filesystem_interface */ public function is_absolute_path($path) { - return \phpbb\storage\helper::is_absolute_path($path); + return \phpbb\filesystem\helper::is_absolute_path($path); } /** @@ -286,7 +286,7 @@ class filesystem implements filesystem_interface */ public function make_path_relative($end_path, $start_path) { - return \phpbb\storage\helper::make_path_relative($end_path, $start_path); + return \phpbb\filesystem\helper::make_path_relative($end_path, $start_path); } /** @@ -759,6 +759,6 @@ class filesystem implements filesystem_interface */ protected function resolve_path($path, $prefix = '', $absolute = false, $return_array = false) { - return \phpbb\storage\helper::resolve_path($path, $prefix, $absolute, $return_array); + return \phpbb\filesystem\helper::resolve_path($path, $prefix, $absolute, $return_array); } } diff --git a/phpBB/phpbb/finder.php b/phpBB/phpbb/finder.php index a1d44c6587..57ae046dc3 100644 --- a/phpBB/phpbb/finder.php +++ b/phpBB/phpbb/finder.php @@ -241,7 +241,7 @@ class finder */ protected function sanitise_directory($directory) { - $directory = \phpbb\storage\helper::clean_path($directory); + $directory = \phpbb\filesystem\helper::clean_path($directory); $dir_len = strlen($directory); if ($dir_len > 1 && $directory[$dir_len - 1] === '/') diff --git a/phpBB/phpbb/install/helper/database.php b/phpBB/phpbb/install/helper/database.php index 3f70536a82..6dbea3735c 100644 --- a/phpBB/phpbb/install/helper/database.php +++ b/phpBB/phpbb/install/helper/database.php @@ -329,7 +329,7 @@ class database // Make sure we don't have a daft user who thinks having the SQLite database in the forum directory is a good idea if ($dbms_info['SCHEMA'] === 'sqlite' - && stripos(\phpbb\storage\helper::realpath($dbhost), \phpbb\storage\helper::realpath($this->phpbb_root_path) === 0)) + && stripos(\phpbb\filesystem\helper::realpath($dbhost), \phpbb\filesystem\helper::realpath($this->phpbb_root_path) === 0)) { $errors[] = array( 'title' =>'INST_ERR_DB_FORUM_PATH', diff --git a/phpBB/phpbb/path_helper.php b/phpBB/phpbb/path_helper.php index 16dd9aa038..8abb62d511 100644 --- a/phpBB/phpbb/path_helper.php +++ b/phpBB/phpbb/path_helper.php @@ -112,7 +112,7 @@ class path_helper $path = substr($path, 8); } - return \phpbb\storage\helper::clean_path($web_root_path . $path); + return \phpbb\filesystem\helper::clean_path($web_root_path . $path); } return $path; @@ -158,7 +158,7 @@ class path_helper // We do not need to escape $path_info, $request_uri and $script_name because we can not find their content in the result. // Path info (e.g. /foo/bar) - $path_info = \phpbb\storage\helper::clean_path($this->symfony_request->getPathInfo()); + $path_info = \phpbb\filesystem\helper::clean_path($this->symfony_request->getPathInfo()); // Full request URI (e.g. phpBB/app.php/foo/bar) $request_uri = $this->symfony_request->getRequestUri(); @@ -173,7 +173,7 @@ class path_helper */ if ($path_info === '/' && preg_match('/app\.' . $this->php_ext . '\/$/', $request_uri)) { - return $this->web_root_path = \phpbb\storage\helper::clean_path('./../' . $this->phpbb_root_path); + return $this->web_root_path = \phpbb\filesystem\helper::clean_path('./../' . $this->phpbb_root_path); } /* @@ -230,7 +230,7 @@ class path_helper } // Prepend ../ to the phpbb_root_path as many times as / exists in path_info - $this->web_root_path = \phpbb\storage\helper::clean_path( + $this->web_root_path = \phpbb\filesystem\helper::clean_path( './' . str_repeat('../', $corrections) . $this->phpbb_root_path ); return $this->web_root_path; @@ -321,7 +321,7 @@ class path_helper // Add length of URL delimiter to position $path = substr($url, $delimiter_position + 3); - return $scheme . \phpbb\storage\helper::clean_path($path); + return $scheme . \phpbb\filesystem\helper::clean_path($path); } /** diff --git a/phpBB/phpbb/routing/file_locator.php b/phpBB/phpbb/routing/file_locator.php index bdf3a2145c..cf4520ddae 100644 --- a/phpBB/phpbb/routing/file_locator.php +++ b/phpBB/phpbb/routing/file_locator.php @@ -24,7 +24,7 @@ class file_locator extends FileLocator foreach ($paths as $path) { - $absolute_paths[] = \phpbb\storage\helper::realpath($path); + $absolute_paths[] = \phpbb\filesystem\helper::realpath($path); } parent::__construct($absolute_paths); diff --git a/phpBB/phpbb/routing/helper.php b/phpBB/phpbb/routing/helper.php index ea8835d362..9c4ead98d2 100644 --- a/phpBB/phpbb/routing/helper.php +++ b/phpBB/phpbb/routing/helper.php @@ -133,7 +133,7 @@ class helper } } - $base_url = $this->request->escape(\phpbb\storage\helper::clean_path($base_url), true); + $base_url = $this->request->escape(\phpbb\filesystem\helper::clean_path($base_url), true); $context->setBaseUrl($base_url); diff --git a/phpBB/phpbb/session.php b/phpBB/phpbb/session.php index 4446e3defd..3a07fa8384 100644 --- a/phpBB/phpbb/session.php +++ b/phpBB/phpbb/session.php @@ -85,15 +85,15 @@ class session $page_name = (substr($script_name, -1, 1) == '/') ? '' : basename($script_name); $page_name = urlencode(htmlspecialchars($page_name)); - $symfony_request_path = \phpbb\storage\helper::clean_path($symfony_request->getPathInfo()); + $symfony_request_path = \phpbb\filesystem\helper::clean_path($symfony_request->getPathInfo()); if ($symfony_request_path !== '/') { $page_name .= str_replace('%2F', '/', urlencode($symfony_request_path)); } // current directory within the phpBB root (for example: adm) - $root_dirs = explode('/', str_replace('\\', '/', \phpbb\storage\helper::realpath($root_path))); - $page_dirs = explode('/', str_replace('\\', '/', \phpbb\storage\helper::realpath('./'))); + $root_dirs = explode('/', str_replace('\\', '/', \phpbb\filesystem\helper::realpath($root_path))); + $page_dirs = explode('/', str_replace('\\', '/', \phpbb\filesystem\helper::realpath('./'))); $intersection = array_intersect_assoc($root_dirs, $page_dirs); $root_dirs = array_diff_assoc($root_dirs, $intersection); diff --git a/phpBB/phpbb/storage/helper.php b/phpBB/phpbb/storage/helper.php deleted file mode 100644 index 4c8dfe466b..0000000000 --- a/phpBB/phpbb/storage/helper.php +++ /dev/null @@ -1,365 +0,0 @@ - - * @license GNU General Public License, version 2 (GPL-2.0) - * - * For full copyright and license information, please see - * the docs/CREDITS.txt file. - * - */ - -namespace phpbb\storage; - -class helper -{ - /** - * Eliminates useless . and .. components from specified path. - * - * @param string $path Path to clean - * - * @return string Cleaned path - */ - public static function clean_path($path) - { - $exploded = explode('/', $path); - $filtered = array(); - foreach ($exploded as $part) - { - if ($part === '.' && !empty($filtered)) - { - continue; - } - - if ($part === '..' && !empty($filtered) && $filtered[sizeof($filtered) - 1] !== '.' && $filtered[sizeof($filtered) - 1] !== '..') - { - array_pop($filtered); - } - else - { - $filtered[] = $part; - } - } - $path = implode('/', $filtered); - return $path; - } - - /** - * Checks if a path is absolute or not - * - * @param string $path Path to check - * - * @return bool true if the path is absolute, false otherwise - */ - public static function is_absolute_path($path) - { - return (isset($path[0]) && $path[0] === '/' || preg_match('#^[a-z]:[/\\\]#i', $path)) ? true : false; - } - - /** - * Try to resolve real path when PHP's realpath failes to do so - * - * @param string $path - * @return bool|string - */ - protected static function phpbb_own_realpath($path) - { - - // Replace all directory separators with '/' - $path = str_replace(DIRECTORY_SEPARATOR, '/', $path); - - $is_absolute_path = false; - $path_prefix = ''; - - if (self::is_absolute_path($path)) - { - $is_absolute_path = true; - } - else - { - if (function_exists('getcwd')) - { - $working_directory = str_replace(DIRECTORY_SEPARATOR, '/', getcwd()); - } - - // - // From this point on we really just guessing - // If chdir were called we screwed - // - else if (function_exists('debug_backtrace')) - { - $call_stack = debug_backtrace(0); - $working_directory = str_replace(DIRECTORY_SEPARATOR, '/', dirname($call_stack[sizeof($call_stack) - 1]['file'])); - } - else - { - // - // Assuming that the working directory is phpBB root - // we could use this as a fallback, when phpBB will use controllers - // everywhere this will be a safe assumption - // - //$dir_parts = explode(DIRECTORY_SEPARATOR, __DIR__); - //$namespace_parts = explode('\\', trim(__NAMESPACE__, '\\')); - - //$namespace_part_count = sizeof($namespace_parts); - - // Check if we still loading from root - //if (array_slice($dir_parts, -$namespace_part_count) === $namespace_parts) - //{ - // $working_directory = implode('/', array_slice($dir_parts, 0, -$namespace_part_count)); - //} - //else - //{ - // $working_directory = false; - //} - - $working_directory = false; - } - - if ($working_directory !== false) - { - $is_absolute_path = true; - $path = $working_directory . '/' . $path; - } - } - - if ($is_absolute_path) - { - if (defined('PHP_WINDOWS_VERSION_MAJOR')) - { - $path_prefix = $path[0] . ':'; - $path = substr($path, 2); - } - else - { - $path_prefix = ''; - } - } - - $resolved_path = self::resolve_path($path, $path_prefix, $is_absolute_path); - if ($resolved_path === false) - { - return false; - } - - if (!@file_exists($resolved_path) || (!@is_dir($resolved_path . '/') && !is_file($resolved_path))) - { - return false; - } - - // Return OS specific directory separators - $resolved = str_replace('/', DIRECTORY_SEPARATOR, $resolved_path); - - // Check for DIRECTORY_SEPARATOR at the end (and remove it!) - if (substr($resolved, -1) === DIRECTORY_SEPARATOR) - { - return substr($resolved, 0, -1); - } - - return $resolved; - } - - /** - * A wrapper for PHP's realpath - * - * Try to resolve realpath when PHP's realpath is not available, or - * known to be buggy. - * - * @param string $path Path to resolve - * - * @return string Resolved path - */ - public static function realpath($path) - { - if (!function_exists('realpath')) - { - return self::phpbb_own_realpath($path); - } - - $realpath = realpath($path); - - // Strangely there are provider not disabling realpath but returning strange values. :o - // We at least try to cope with them. - if ((!self::is_absolute_path($path) && $realpath === $path) || $realpath === false) - { - return self::phpbb_own_realpath($path); - } - - // Check for DIRECTORY_SEPARATOR at the end (and remove it!) - if (substr($realpath, -1) === DIRECTORY_SEPARATOR) - { - $realpath = substr($realpath, 0, -1); - } - - return $realpath; - } - - /** - * Given an existing path, convert it to a path relative to a given starting path - * - * @param string $end_path Absolute path of target - * @param string $start_path Absolute path where traversal begins - * - * @return string Path of target relative to starting path - */ - public static function make_path_relative($end_path, $start_path) - { - $symfony_filesystem = new \Symfony\Component\Filesystem\Filesystem(); - return $symfony_filesystem->makePathRelative($end_path, $start_path); - } - - /** - * Try to resolve symlinks in path - * - * @param string $path The path to resolve - * @param string $prefix The path prefix (on windows the drive letter) - * @param bool $absolute Whether or not the path is absolute - * @param bool $return_array Whether or not to return path parts - * - * @return string|array|bool returns the resolved path or an array of parts of the path if $return_array is true - * or false if path cannot be resolved - */ - protected static function resolve_path($path, $prefix = '', $absolute = false, $return_array = false) - { - if ($return_array) - { - $path = str_replace(DIRECTORY_SEPARATOR, '/', $path); - } - - trim ($path, '/'); - $path_parts = explode('/', $path); - $resolved = array(); - $resolved_path = $prefix; - $file_found = false; - - foreach ($path_parts as $path_part) - { - if ($file_found) - { - return false; - } - - if (empty($path_part) || ($path_part === '.' && ($absolute || !empty($resolved)))) - { - continue; - } - else if ($absolute && $path_part === '..') - { - if (empty($resolved)) - { - // No directories above root - return false; - } - - array_pop($resolved); - $resolved_path = false; - } - else if ($path_part === '..' && !empty($resolved) && !in_array($resolved[sizeof($resolved) - 1], array('.', '..'))) - { - array_pop($resolved); - $resolved_path = false; - } - else - { - if ($resolved_path === false) - { - if (empty($resolved)) - { - $resolved_path = ($absolute) ? $prefix . '/' . $path_part : $path_part; - } - else - { - $tmp_array = $resolved; - if ($absolute) - { - array_unshift($tmp_array, $prefix); - } - - $resolved_path = implode('/', $tmp_array); - } - } - - $current_path = $resolved_path . '/' . $path_part; - - // Resolve symlinks - if (is_link($current_path)) - { - if (!function_exists('readlink')) - { - return false; - } - - $link = readlink($current_path); - - // Is link has an absolute path in it? - if (self::is_absolute_path($link)) - { - if (defined('PHP_WINDOWS_VERSION_MAJOR')) - { - $prefix = $link[0] . ':'; - $link = substr($link, 2); - } - else - { - $prefix = ''; - } - - $resolved = self::resolve_path($link, $prefix, true, true); - $absolute = true; - } - else - { - $resolved = self::resolve_path($resolved_path . '/' . $link, $prefix, $absolute, true); - } - - if (!$resolved) - { - return false; - } - - $resolved_path = false; - } - else if (is_dir($current_path . '/')) - { - $resolved[] = $path_part; - $resolved_path = $current_path; - } - else if (is_file($current_path)) - { - $resolved[] = $path_part; - $resolved_path = $current_path; - $file_found = true; - } - else - { - return false; - } - } - } - - // If at the end of the path there were a .. or . - // we need to build the path again. - // Only doing this when a string is expected in return - if ($resolved_path === false && $return_array === false) - { - if (empty($resolved)) - { - $resolved_path = ($absolute) ? $prefix . '/' : './'; - } - else - { - $tmp_array = $resolved; - if ($absolute) - { - array_unshift($tmp_array, $prefix); - } - - $resolved_path = implode('/', $tmp_array); - } - } - - return ($return_array) ? $resolved : $resolved_path; - } -} diff --git a/phpBB/phpbb/template/asset.php b/phpBB/phpbb/template/asset.php index b7469c7e06..6acd816db5 100644 --- a/phpBB/phpbb/template/asset.php +++ b/phpBB/phpbb/template/asset.php @@ -153,7 +153,7 @@ class asset public function set_path($path, $urlencode = false) { // Since 1.7.0 Twig returns the real path of the file. We need it to be relative. - $real_root_path = \phpbb\storage\helper::realpath($this->path_helper->get_phpbb_root_path()) . DIRECTORY_SEPARATOR; + $real_root_path = \phpbb\filesystem\helper::realpath($this->path_helper->get_phpbb_root_path()) . DIRECTORY_SEPARATOR; // If the asset is under the phpBB root path we need to remove its path and then prepend $phpbb_root_path if ($real_root_path && substr($path . DIRECTORY_SEPARATOR, 0, strlen($real_root_path)) === $real_root_path) @@ -163,7 +163,7 @@ class asset else { // Else we make the path relative to the current working directory - $real_root_path = \phpbb\storage\helper::realpath('.') . DIRECTORY_SEPARATOR; + $real_root_path = \phpbb\filesystem\helper::realpath('.') . DIRECTORY_SEPARATOR; if ($real_root_path && substr($path . DIRECTORY_SEPARATOR, 0, strlen($real_root_path)) === $real_root_path) { $path = str_replace('\\', '/', substr($path, strlen($real_root_path))); diff --git a/phpBB/phpbb/template/twig/loader.php b/phpBB/phpbb/template/twig/loader.php index 6fa7eda2cc..121c93b170 100644 --- a/phpBB/phpbb/template/twig/loader.php +++ b/phpBB/phpbb/template/twig/loader.php @@ -49,7 +49,7 @@ class loader extends \Twig_Loader_Filesystem */ public function addSafeDirectory($directory) { - $directory = \phpbb\storage\helper::realpath($directory); + $directory = \phpbb\filesystem\helper::realpath($directory); if ($directory !== false) { @@ -89,7 +89,7 @@ class loader extends \Twig_Loader_Filesystem */ public function addPath($path, $namespace = self::MAIN_NAMESPACE) { - return parent::addPath(\phpbb\storage\helper::realpath($path), $namespace); + return parent::addPath(\phpbb\filesystem\helper::realpath($path), $namespace); } /** @@ -129,7 +129,7 @@ class loader extends \Twig_Loader_Filesystem // can now check if we're within a "safe" directory // Find the real path of the directory the file is in - $directory = \phpbb\storage\helper::realpath(dirname($file)); + $directory = \phpbb\filesystem\helper::realpath(dirname($file)); if ($directory === false) { diff --git a/phpBB/phpbb/viewonline_helper.php b/phpBB/phpbb/viewonline_helper.php index e034b20a56..ee23190db8 100644 --- a/phpBB/phpbb/viewonline_helper.php +++ b/phpBB/phpbb/viewonline_helper.php @@ -33,7 +33,7 @@ class viewonline_helper */ public function get_user_page($session_page) { - $session_page = \phpbb\storage\helper::clean_path($session_page); + $session_page = \phpbb\filesystem\helper::clean_path($session_page); if (strpos($session_page, './') === 0) { $session_page = substr($session_page, 2); diff --git a/tests/di/fixtures/ext/vendor/enabled_4/di/extension.php b/tests/di/fixtures/ext/vendor/enabled_4/di/extension.php index 5e5f07c777..cd94902276 100644 --- a/tests/di/fixtures/ext/vendor/enabled_4/di/extension.php +++ b/tests/di/fixtures/ext/vendor/enabled_4/di/extension.php @@ -25,7 +25,7 @@ class extension extends extension_base { protected function load_services(ContainerBuilder $container) { - $loader = new YamlFileLoader($container, new FileLocator(\phpbb\storage\helper::realpath($this->ext_path))); + $loader = new YamlFileLoader($container, new FileLocator(\phpbb\filesystem\helper::realpath($this->ext_path))); $loader->load('environment.yml'); } } diff --git a/tests/path_helper/path_helper_test.php b/tests/path_helper/path_helper_test.php index 29dee8cced..96b8460f04 100644 --- a/tests/path_helper/path_helper_test.php +++ b/tests/path_helper/path_helper_test.php @@ -43,7 +43,7 @@ class phpbb_path_helper_test extends phpbb_test_case */ public function set_phpbb_root_path() { - $this->phpbb_root_path = \phpbb\storage\helper::clean_path(dirname(__FILE__) . '/../../phpBB/'); + $this->phpbb_root_path = \phpbb\filesystem\helper::clean_path(dirname(__FILE__) . '/../../phpBB/'); } public function test_get_web_root_path() @@ -72,7 +72,7 @@ class phpbb_path_helper_test extends phpbb_test_case ), array( $this->phpbb_root_path . $this->phpbb_root_path . 'test.php', - \phpbb\storage\helper::clean_path($this->phpbb_root_path . $this->phpbb_root_path . 'test.php'), + \phpbb\filesystem\helper::clean_path($this->phpbb_root_path . $this->phpbb_root_path . 'test.php'), ), ); } diff --git a/tests/storage/helper_clean_path_test.php b/tests/storage/helper_clean_path_test.php deleted file mode 100644 index ab9fabd0cb..0000000000 --- a/tests/storage/helper_clean_path_test.php +++ /dev/null @@ -1,52 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -class phpbb_storage_helper_clean_path_test extends phpbb_test_case -{ - - public function setUp() - { - parent::setUp(); - } - - public function clean_path_data() - { - return array( - array('foo', 'foo'), - array('foo/bar', 'foo/bar'), - array('foo/bar/', 'foo/bar/'), - array('foo/./bar', 'foo/bar'), - array('foo/./././bar', 'foo/bar'), - array('foo/bar/.', 'foo/bar'), - array('./foo/bar', './foo/bar'), - array('../foo/bar', '../foo/bar'), - array('./../foo/bar', './../foo/bar'), - array('././../foo/bar', './../foo/bar'), - array('one/two/three', 'one/two/three'), - array('one/two/../three', 'one/three'), - array('one/../two/three', 'two/three'), - array('one/two/..', 'one'), - array('one/two/../', 'one/'), - array('one/two/../three/../four', 'one/four'), - array('one/two/three/../../four', 'one/four'), - ); - } - - /** - * @dataProvider clean_path_data - */ - public function test_clean_path($input, $expected) - { - $this->assertEquals($expected, \phpbb\storage\helper::clean_path($input)); - } -} diff --git a/tests/storage/helper_is_absolute_test.php b/tests/storage/helper_is_absolute_test.php deleted file mode 100644 index 05a048cb91..0000000000 --- a/tests/storage/helper_is_absolute_test.php +++ /dev/null @@ -1,64 +0,0 @@ - - * @license GNU General Public License, version 2 (GPL-2.0) - * - * For full copyright and license information, please see - * the docs/CREDITS.txt file. - * - */ - -class phpbb_storage_helper_is_absolute_test extends phpbb_test_case -{ - - public function setUp() - { - parent::setUp(); - } - - static public function is_absolute_data() - { - return array( - // Empty - array('', false), - - // Absolute unix style - array('/etc/phpbb', true), - // Unix does not support \ so that is not an absolute path - array('\etc\phpbb', false), - - // Absolute windows style - array('c:\windows', true), - array('C:\Windows', true), - array('c:/windows', true), - array('C:/Windows', true), - - // Executable - array('etc/phpbb', false), - array('explorer.exe', false), - - // Relative subdir - array('Windows\System32', false), - array('Windows\System32\explorer.exe', false), - array('Windows/System32', false), - array('Windows/System32/explorer.exe', false), - - // Relative updir - array('..\Windows\System32', false), - array('..\Windows\System32\explorer.exe', false), - array('../Windows/System32', false), - array('../Windows/System32/explorer.exe', false), - ); - } - - /** - * @dataProvider is_absolute_data - */ - public function test_is_absolute($path, $expected) - { - $this->assertEquals($expected, \phpbb\storage\helper::is_absolute_path($path)); - } -} diff --git a/tests/storage/helper_realpath_test.php b/tests/storage/helper_realpath_test.php deleted file mode 100644 index 1cc5e4b1ce..0000000000 --- a/tests/storage/helper_realpath_test.php +++ /dev/null @@ -1,83 +0,0 @@ - - * @license GNU General Public License, version 2 (GPL-2.0) - * - * For full copyright and license information, please see - * the docs/CREDITS.txt file. - * - */ - -class phpbb_storage_helper_realpath_test extends phpbb_test_case -{ - protected static $storage_helper_phpbb_own_realpath; - - static public function setUpBeforeClass() - { - parent::setUpBeforeClass(); - - self::$storage_helper_phpbb_own_realpath = new ReflectionMethod('\phpbb\storage\helper', 'phpbb_own_realpath'); - self::$storage_helper_phpbb_own_realpath->setAccessible(true); - } - - public function setUp() - { - parent::setUp(); - } - - public function realpath_resolve_absolute_without_symlinks_data() - { - return array( - // Constant data - array(__DIR__, __DIR__), - array(__DIR__ . '/../storage/../storage', __DIR__), - array(__DIR__ . '/././', __DIR__), - array(__DIR__ . '/non_existent', false), - - array(__FILE__, __FILE__), - array(__FILE__ . '../', false), - ); - } - - public function realpath_resolve_relative_without_symlinks_data() - { - if (!function_exists('getcwd')) - { - return array(); - } - - $relative_path = \phpbb\storage\helper::make_path_relative(__DIR__, getcwd()); - - return array( - array($relative_path, __DIR__), - array($relative_path . '../storage/../storage', __DIR__), - array($relative_path . '././', __DIR__), - - array($relative_path . 'helper_realpath_test.php', __FILE__), - ); - } - - /** - * @dataProvider realpath_resolve_absolute_without_symlinks_data - */ - public function test_realpath_absolute_without_links($path, $expected) - { - $this->assertEquals($expected, self::$storage_helper_phpbb_own_realpath->invoke(null, $path)); - } - - /** - * @dataProvider realpath_resolve_relative_without_symlinks_data - */ - public function test_realpath_relative_without_links($path, $expected) - { - if (!function_exists('getcwd')) - { - $this->markTestSkipped('phpbb_own_realpath() cannot be tested with relative paths: getcwd is not available.'); - } - - $this->assertEquals($expected, self::$storage_helper_phpbb_own_realpath->invoke(null, $path)); - } -} diff --git a/tests/template/includephp_test.php b/tests/template/includephp_test.php index 7d34252673..e156be5c23 100644 --- a/tests/template/includephp_test.php +++ b/tests/template/includephp_test.php @@ -40,7 +40,7 @@ class phpbb_template_includephp_test extends phpbb_template_template_test_case global $phpbb_root_path; $path_to_php = str_replace('\\', '/', dirname(__FILE__)) . '/templates/_dummy_include.php.inc'; - $this->assertTrue(\phpbb\storage\helper::is_absolute_path($path_to_php)); + $this->assertTrue(\phpbb\filesystem\helper::is_absolute_path($path_to_php)); $template_text = "Path is absolute.\n"; $cache_dir = $phpbb_root_path . 'cache/';