diff options
| author | Joas Schilling <nickvergessen@gmx.de> | 2013-11-12 22:25:23 +0100 |
|---|---|---|
| committer | Joas Schilling <nickvergessen@gmx.de> | 2013-11-13 11:30:13 +0100 |
| commit | 0a7db81426e966f9c44fcc85338615e1bb3c6f34 (patch) | |
| tree | ace529f2b9204221a0191f9f70805f209e4856de | |
| parent | d43542a434c6a214c7533f76f3b1dc7afe84e5cf (diff) | |
| download | forums-0a7db81426e966f9c44fcc85338615e1bb3c6f34.tar forums-0a7db81426e966f9c44fcc85338615e1bb3c6f34.tar.gz forums-0a7db81426e966f9c44fcc85338615e1bb3c6f34.tar.bz2 forums-0a7db81426e966f9c44fcc85338615e1bb3c6f34.tar.xz forums-0a7db81426e966f9c44fcc85338615e1bb3c6f34.zip | |
[ticket/11997] Fix redirects from inside controllers
The redirect url currently uses the web root path. However as we prepend the
full board url later, we need to remove the relative web root path and prepend
the normal root path again. Otherwise redirects from inside routes will not
work as intended.
PHPBB3-11997
| -rw-r--r-- | phpBB/includes/functions.php | 10 | ||||
| -rw-r--r-- | phpBB/phpbb/path_helper.php | 21 |
2 files changed, 31 insertions, 0 deletions
diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 0a10a9604c..c937b8f562 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -2662,6 +2662,16 @@ function redirect($url, $return = false, $disable_cd_check = false) // Make sure no &'s are in, this will break the redirect $url = str_replace('&', '&', $url); + // The url currently uses the web root path. + // However as we prepend the full board url later, + // we need to remove the relative web root path and + // prepend the normal root path again. Otherwise redirects + // from inside routes will not work as intended. + if ($phpbb_path_helper instanceof \phpbb\path_helper) + { + $url = $phpbb_path_helper->remove_web_root_path($url); + } + // Determine which type of redirect we need to handle... $url_parts = @parse_url($url); diff --git a/phpBB/phpbb/path_helper.php b/phpBB/phpbb/path_helper.php index 8cd8808261..71252ac05b 100644 --- a/phpBB/phpbb/path_helper.php +++ b/phpBB/phpbb/path_helper.php @@ -102,6 +102,27 @@ class path_helper } /** + * Strips away the web root path and prepends the normal root path + * + * This replaces get_web_root_path() . some_url with + * $phpbb_root_path . some_url + * + * @param string $path The path to be updated + * @return string + */ + public function remove_web_root_path($path) + { + if (strpos($path, $this->get_web_root_path()) === 0) + { + $path = substr($path, strlen($this->get_web_root_path())); + + return $this->phpbb_root_path . $path; + } + + return $path; + } + + /** * Get a relative root path from the current URL * * @return string |
