diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2013-11-26 17:13:33 +0400 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2013-11-27 01:34:25 +0400 |
commit | 4221490d04f1f02e89c5f06f6250fb9ec113eac9 (patch) | |
tree | aa2fa083872c54b0cb908c3be09867be2747eb1a /lib | |
parent | 113040676322ea7316f843bdbc990a3e8deadf7d (diff) |
fixes #6050
Diffstat (limited to 'lib')
-rwxr-xr-x | lib/request.php | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/lib/request.php b/lib/request.php index 770ccd5bdb2..dc8e3e61be3 100755 --- a/lib/request.php +++ b/lib/request.php @@ -141,17 +141,30 @@ class OC_Request { $requestUri = '/' . ltrim($requestUri, '/'); } + // Remove the query string from REQUEST_URI + if ($pos = strpos($requestUri, '?')) { + $requestUri = substr($requestUri, 0, $pos); + } + $scriptName = $_SERVER['SCRIPT_NAME']; - // in case uri and script name don't match we better throw an exception - if (strpos($requestUri, $scriptName) !== 0) { - throw new Exception("REQUEST_URI($requestUri) does not start with the SCRIPT_NAME($scriptName)"); + $path_info = $requestUri; + + // strip off the script name's dir and file name + list($path, $name) = \Sabre_DAV_URLUtil::splitPath($scriptName); + if (!empty($path)) { + if( $path === $path_info || strpos($path_info, $path.'/') === 0) { + $path_info = substr($path_info, strlen($path)); + } else { + throw new Exception("The requested uri($requestUri) cannot be processed by the script '$scriptName')"); + } } - $path_info = substr($requestUri, strlen($scriptName)); - // Remove the query string from REQUEST_URI - if ($pos = strpos($path_info, '?')) { - $path_info = substr($path_info, 0, $pos); + if (strpos($path_info, '/'.$name.'/') === 0) { + $path_info = substr($path_info, strlen($name) + 1); } - return $path_info; + if (strpos($path_info, $name) === 0) { + $path_info = substr($path_info, strlen($name)); + } + return rtrim($path_info, '/'); } /** |