mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-30 21:40:43 +02:00
Merge remote-tracking branch 'Marc/ticket/11997' into develop
* Marc/ticket/11997: (23 commits) [ticket/11997] Use functional test cases that should always work [ticket/11997] Fix redirect tests for mod rewrite [ticket/11997] Add user's page dir to redirect path and fix unit tests for it [ticket/11997] Remove obsolete function get_controller_redirect_url() [ticket/11997] Use path_helper in in foo/bar extension for redirect URLs [ticket/11997] Add remove_web_root_path() in order to prevent incorrect URLs [ticket/11997] Do not check if file or dir we redirect to exist [ticket/11997] Modifiy tests after adding path_helper clean_url method [ticket/11997] Add clean_url() method to path_helper [ticket/11997] Allow redirects to parent folders like previously [ticket/11997] Move expected redirect returns to controller and output to HTML [ticket/11997] Fix tests for path_helper's get_controller_redirect_url() [ticket/11997] Use get_controller_redirect_url() in redirect() function [ticket/11997] Add method for controller redirect URLs to path helper [ticket/11997] Undo changes to phpbb_own_realpath() [ticket/11997] Remove obsolete failover_flag in function redirect() [ticket/11997] Add functional test for redirects in controller [ticket/11997] Fix missing global [ticket/11997] Fix redirects from inside controllers [ticket/11997] Use $phpbb_filesystem->clean_path() for proper redirect paths ...
This commit is contained in:
@@ -101,6 +101,27 @@ class path_helper
|
||||
return $path;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*
|
||||
@@ -162,4 +183,27 @@ class path_helper
|
||||
*/
|
||||
return $this->web_root_path = $this->phpbb_root_path . str_repeat('../', $corrections - 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Eliminates useless . and .. components from specified URL
|
||||
*
|
||||
* @param string $url URL to clean
|
||||
*
|
||||
* @return string Cleaned URL
|
||||
*/
|
||||
public function clean_url($url)
|
||||
{
|
||||
$delimiter_position = strpos($url, '://');
|
||||
// URL should contain :// but it shouldn't start with it.
|
||||
// Do not clean URLs that do not fit these constraints.
|
||||
if (empty($delimiter_position))
|
||||
{
|
||||
return $url;
|
||||
}
|
||||
$scheme = substr($url, 0, $delimiter_position) . '://';
|
||||
// Add length of URL delimiter to position
|
||||
$path = substr($url, $delimiter_position + 3);
|
||||
|
||||
return $scheme . $this->filesystem->clean_path($path);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user