diff options
Diffstat (limited to 'lib/private/request.php')
-rwxr-xr-x | lib/private/request.php | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/private/request.php b/lib/private/request.php index d11e5b16cfe..7a75bf25208 100755 --- a/lib/private/request.php +++ b/lib/private/request.php @@ -136,7 +136,18 @@ class OC_Request { * @returns string Path info or false when not found */ public static function getRawPathInfo() { - $path_info = substr($_SERVER['REQUEST_URI'], strlen($_SERVER['SCRIPT_NAME'])); + $requestUri = $_SERVER['REQUEST_URI']; + // remove too many leading slashes - can be caused by reverse proxy configuration + if (strpos($requestUri, '/') === 0) { + $requestUri = '/' . ltrim($requestUri, '/'); + } + + $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 = substr($requestUri, strlen($scriptName)); // Remove the query string from REQUEST_URI if ($pos = strpos($path_info, '?')) { $path_info = substr($path_info, 0, $pos); |