Ensure that passed argument is always a string

Some code paths called the `normalizePath` functionality with types other than a string which resulted in unexpected behaviour.

Thus the function is now manually casting the type to a string and I corrected the usage in list.php as well.
This commit is contained in:
Lukas Reschke 2015-02-13 12:49:34 +01:00
parent 51f8d240c1
commit 9904b30070
2 changed files with 10 additions and 1 deletions

View File

@ -5,7 +5,7 @@ OCP\JSON::checkLoggedIn();
$l = \OC::$server->getL10N('files');
// Load the files
$dir = isset($_GET['dir']) ? $_GET['dir'] : '';
$dir = isset($_GET['dir']) ? (string)$_GET['dir'] : '';
$dir = \OC\Files\Filesystem::normalizePath($dir);
try {

View File

@ -723,9 +723,18 @@ class Filesystem {
* Fix common problems with a file path
* @param string $path
* @param bool $stripTrailingSlash
* @param bool $isAbsolutePath
* @return string
*/
public static function normalizePath($path, $stripTrailingSlash = true, $isAbsolutePath = false) {
/**
* FIXME: This is a workaround for existing classes and files which call
* this function with another type than a valid string. This
* conversion should get removed as soon as all existing
* function calls have been fixed.
*/
$path = (string)$path;
$cacheKey = json_encode([$path, $stripTrailingSlash, $isAbsolutePath]);
if(isset(self::$normalizedPathCache[$cacheKey])) {