diff options
author | Lukas Reschke <lukas@owncloud.com> | 2015-02-13 12:49:34 +0100 |
---|---|---|
committer | Lukas Reschke <lukas@owncloud.com> | 2015-06-01 17:06:16 +0200 |
commit | 5fa749cd9656ca6eab30bac0ef4e7625b8a8be2e (patch) | |
tree | a6113361f900509241e5711569c82336e834c9f9 | |
parent | a15710afad054953cc348f2dd719c73b60985bce (diff) | |
download | nextcloud-server-5fa749cd9656ca6eab30bac0ef4e7625b8a8be2e.tar.gz nextcloud-server-5fa749cd9656ca6eab30bac0ef4e7625b8a8be2e.zip |
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.
-rw-r--r-- | apps/files/ajax/list.php | 2 | ||||
-rw-r--r-- | lib/private/files/filesystem.php | 9 |
2 files changed, 10 insertions, 1 deletions
diff --git a/apps/files/ajax/list.php b/apps/files/ajax/list.php index 49080167e29..21c88e28b9d 100644 --- a/apps/files/ajax/list.php +++ b/apps/files/ajax/list.php @@ -5,7 +5,7 @@ OCP\JSON::checkLoggedIn(); $l = OC_L10N::get('files'); // Load the files -$dir = isset($_GET['dir']) ? $_GET['dir'] : ''; +$dir = isset($_GET['dir']) ? (string)$_GET['dir'] : ''; $dir = \OC\Files\Filesystem::normalizePath($dir); try { diff --git a/lib/private/files/filesystem.php b/lib/private/files/filesystem.php index 03fbe31feab..883bd4fc6b4 100644 --- a/lib/private/files/filesystem.php +++ b/lib/private/files/filesystem.php @@ -694,9 +694,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; + if ($path == '') { return '/'; } |