Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2013-11-26 17:13:33 +0400
committerThomas Müller <thomas.mueller@tmit.eu>2013-11-27 01:34:25 +0400
commit4221490d04f1f02e89c5f06f6250fb9ec113eac9 (patch)
treeaa2fa083872c54b0cb908c3be09867be2747eb1a /lib
parent113040676322ea7316f843bdbc990a3e8deadf7d (diff)
fixes #6050
Diffstat (limited to 'lib')
-rwxr-xr-xlib/request.php29
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, '/');
}
/**