Merge pull request #1972 from owncloud/raw-pathinfo

Use the plain urlencoded path info for the routing matching
This commit is contained in:
Bernhard Posselt 2013-02-27 13:43:47 -08:00
commit 2f036bcc54
2 changed files with 15 additions and 2 deletions

View File

@ -597,7 +597,7 @@ class OC {
if (!self::$CLI) { if (!self::$CLI) {
try { try {
OC_App::loadApps(); OC_App::loadApps();
OC::getRouter()->match(OC_Request::getPathInfo()); OC::getRouter()->match(OC_Request::getRawPathInfo());
return; return;
} catch (Symfony\Component\Routing\Exception\ResourceNotFoundException $e) { } catch (Symfony\Component\Routing\Exception\ResourceNotFoundException $e) {
//header('HTTP/1.0 404 Not Found'); //header('HTTP/1.0 404 Not Found');

View File

@ -107,7 +107,7 @@ class OC_Request {
if (array_key_exists('PATH_INFO', $_SERVER)) { if (array_key_exists('PATH_INFO', $_SERVER)) {
$path_info = $_SERVER['PATH_INFO']; $path_info = $_SERVER['PATH_INFO'];
}else{ }else{
$path_info = substr($_SERVER['REQUEST_URI'], strlen($_SERVER['SCRIPT_NAME'])); $path_info = self::getRawPathInfo();
// following is taken from Sabre_DAV_URLUtil::decodePathSegment // following is taken from Sabre_DAV_URLUtil::decodePathSegment
$path_info = rawurldecode($path_info); $path_info = rawurldecode($path_info);
$encoding = mb_detect_encoding($path_info, array('UTF-8', 'ISO-8859-1')); $encoding = mb_detect_encoding($path_info, array('UTF-8', 'ISO-8859-1'));
@ -123,6 +123,19 @@ class OC_Request {
return $path_info; return $path_info;
} }
/**
* @brief get Path info from request, not urldecoded
* @returns string Path info or false when not found
*/
public static function getRawPathInfo() {
$path_info = substr($_SERVER['REQUEST_URI'], strlen($_SERVER['SCRIPT_NAME']));
// Remove the query string from REQUEST_URI
if ($pos = strpos($path_info, '?')) {
$path_info = substr($path_info, 0, $pos);
}
return $path_info;
}
/** /**
* @brief Check if this is a no-cache request * @brief Check if this is a no-cache request
* @returns true for no-cache * @returns true for no-cache