summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLukas Reschke <lukas@owncloud.com>2015-02-13 12:49:34 +0100
committerLukas Reschke <lukas@owncloud.com>2015-06-01 17:07:03 +0200
commit5154cc3e2c0e9d7f0a0e44d1609f3c3b83ccc402 (patch)
tree8b80767a37346b361f060283c0163a28ff399245
parentbf0f1a50926a75a26a42a3da4d62e84a489ee77a (diff)
downloadnextcloud-server-5154cc3e2c0e9d7f0a0e44d1609f3c3b83ccc402.tar.gz
nextcloud-server-5154cc3e2c0e9d7f0a0e44d1609f3c3b83ccc402.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.php2
-rw-r--r--lib/private/files/filesystem.php8
2 files changed, 9 insertions, 1 deletions
diff --git a/apps/files/ajax/list.php b/apps/files/ajax/list.php
index 0be38c3b96f..d32f8e0d950 100644
--- a/apps/files/ajax/list.php
+++ b/apps/files/ajax/list.php
@@ -9,7 +9,7 @@ $RUNTIME_APPTYPES=array('filesystem');
OCP\JSON::checkLoggedIn();
// Load the files
-$dir = isset( $_GET['dir'] ) ? $_GET['dir'] : '';
+$dir = isset($_GET['dir']) ? (string)$_GET['dir'] : '';
$dir = \OC\Files\Filesystem::normalizePath($dir);
if (!\OC\Files\Filesystem::is_dir($dir . '/')) {
header("HTTP/1.0 404 Not Found");
diff --git a/lib/private/files/filesystem.php b/lib/private/files/filesystem.php
index 7b031cb88c7..5e6bdfaa4ef 100644
--- a/lib/private/files/filesystem.php
+++ b/lib/private/files/filesystem.php
@@ -616,6 +616,14 @@ class Filesystem {
* @return string
*/
public static function normalizePath($path, $stripTrailingSlash = true) {
+ /**
+ * 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 '/';
}