From 7ec6dd75f388bf449016d78e39c93d3c13f99e69 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Thu, 4 Feb 2016 00:23:42 +0100 Subject: [PATCH 1/3] [ticket/14440] Correctly remove the web root path in update_web_root_path PHPBB3-14440 --- phpBB/phpbb/path_helper.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/phpBB/phpbb/path_helper.php b/phpBB/phpbb/path_helper.php index 7b0d6f0fba..c5e006120a 100644 --- a/phpBB/phpbb/path_helper.php +++ b/phpBB/phpbb/path_helper.php @@ -100,11 +100,17 @@ class path_helper */ public function update_web_root_path($path) { + $web_root_path = $this->get_web_root_path(); + + if (strpos($path, $web_root_path) === 0) + { + $path = $this->phpbb_root_path . substr($path, strlen($web_root_path)); + } + if (strpos($path, $this->phpbb_root_path) === 0) { $path = substr($path, strlen($this->phpbb_root_path)); - $web_root_path = $this->get_web_root_path(); if (substr($web_root_path, -8) === 'app.php/' && substr($path, 0, 7) === 'app.php') { $path = substr($path, 8); From 20d85433fcba5dd892a7f82b8be2bac34546536f Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Sun, 7 Feb 2016 15:15:01 +0100 Subject: [PATCH 2/3] =?UTF-8?q?[ticket/14440]=C2=A0Add=20tests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PHPBB3-14440 --- tests/path_helper/path_helper_test.php | 37 ++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/tests/path_helper/path_helper_test.php b/tests/path_helper/path_helper_test.php index 007441bc92..49dd40fbec 100644 --- a/tests/path_helper/path_helper_test.php +++ b/tests/path_helper/path_helper_test.php @@ -135,6 +135,43 @@ class phpbb_path_helper_test extends phpbb_test_case '/phpbb3-fork/phpBB/app.php', './../', ), + + // No correction if the path is already prepend by the web root path + array( + './../' . $this->phpbb_root_path . 'test.php', + '//', + null, + null, + '', + ), + array( + './../' . $this->phpbb_root_path . 'test.php', + '//', + 'foo/bar.php', + 'bar.php', + '', + ), + array( + './../../' . $this->phpbb_root_path . 'test.php', + '/foo/template', + '/phpbb3-fork/phpBB/app.php/foo/template', + '/phpbb3-fork/phpBB/app.php', + '', + ), + array( + './../' . $this->phpbb_root_path . 'test.php', + '/foo/template', + '/phpbb3-fork/phpBB/foo/template', + '/phpbb3-fork/phpBB/app.php', + '', + ), + array( + './../'.$this->phpbb_root_path . 'test.php', + '/', + '/phpbb3-fork/phpBB/app.php/', + '/phpbb3-fork/phpBB/app.php', + '', + ), ); } From 5557760eccab67515990622471bd5de297e40f1e Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Thu, 11 Feb 2016 22:18:09 +0100 Subject: [PATCH 3/3] [ticket/14440] Add comments PHPBB3-14440 --- phpBB/phpbb/path_helper.php | 1 + 1 file changed, 1 insertion(+) diff --git a/phpBB/phpbb/path_helper.php b/phpBB/phpbb/path_helper.php index c5e006120a..154361ef64 100644 --- a/phpBB/phpbb/path_helper.php +++ b/phpBB/phpbb/path_helper.php @@ -102,6 +102,7 @@ class path_helper { $web_root_path = $this->get_web_root_path(); + // Removes the web root path if it is already present if (strpos($path, $web_root_path) === 0) { $path = $this->phpbb_root_path . substr($path, strlen($web_root_path));