diff options
author | Bjoern Schiessle <schiessle@owncloud.com> | 2013-11-26 19:15:53 +0100 |
---|---|---|
committer | Bjoern Schiessle <schiessle@owncloud.com> | 2013-11-26 19:15:53 +0100 |
commit | 7240d349da32af187b1920d8cf1cf67d81d268a1 (patch) | |
tree | 27e42cfe58e7de000ee4c0899a3c3afc8537079e /lib/private/request.php | |
parent | c7e1fe50c23771995bebf218c18deaf12ba628ca (diff) | |
parent | 1fef97f6a535cd79d0aea600634ec54c5f87bcea (diff) | |
download | nextcloud-server-7240d349da32af187b1920d8cf1cf67d81d268a1.tar.gz nextcloud-server-7240d349da32af187b1920d8cf1cf67d81d268a1.zip |
Merge branch 'master' into encryption_initial_enc_indicator
Diffstat (limited to 'lib/private/request.php')
-rwxr-xr-x | lib/private/request.php | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/lib/private/request.php b/lib/private/request.php index 7a75bf25208..37d918d2032 100755 --- a/lib/private/request.php +++ b/lib/private/request.php @@ -142,17 +142,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, '/'); } /** |