]> source.dussan.org Git - nextcloud-server.git/commitdiff
Ensure that passed argument is always a string
authorLukas Reschke <lukas@owncloud.com>
Fri, 13 Feb 2015 11:49:34 +0000 (12:49 +0100)
committerLukas Reschke <lukas@owncloud.com>
Fri, 13 Feb 2015 11:49:34 +0000 (12:49 +0100)
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.

apps/files/ajax/list.php
lib/private/files/filesystem.php

index 4aed79d70f77911c132bdd06afd3d656b1bf26dd..b590776830a052950c96488ce3da1f572ddae873 100644 (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 {
index e933782ce2fcc277c58d8e1cbfb4bd324bace095..04f82d88cd126f396bea7bda317dd5147e5576dd 100644 (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])) {