]> source.dussan.org Git - nextcloud-server.git/commitdiff
only escape glob pattern
authorBjörn Schießle <schiessle@owncloud.com>
Tue, 25 Jun 2013 14:50:10 +0000 (16:50 +0200)
committerBjörn Schießle <schiessle@owncloud.com>
Fri, 5 Jul 2013 14:00:17 +0000 (16:00 +0200)
apps/files_encryption/hooks/hooks.php
apps/files_encryption/lib/keymanager.php

index 96f06b154f82f98bb94e129b65afc5b2ab6150a9..c26119b6c2efb5c5ac071cb50cd96ce0d9b5b42c 100644 (file)
@@ -497,7 +497,8 @@ class Hooks {
 \r
                        // handle share-keys\r
                        $localKeyPath = $view->getLocalFile($baseDir . 'share-keys/' . $params['oldpath']);\r
-                       $matches = glob(preg_quote($localKeyPath) . '*.shareKey');\r
+                       $escapedPath = preg_replace('/(\*|\?|\[)/', '[$1]', $localKeyPath);\r
+                       $matches = glob($escapedPath . '*.shareKey');\r
                        foreach ($matches as $src) {\r
                                $dst = \OC\Files\Filesystem::normalizePath(str_replace($params['oldpath'], $params['newpath'], $src));\r
 \r
index 8de1d413642578abcd8cf98c226059850d992b42..da2ee380e89bc780cb9b57c37e838dbfcf559d52 100755 (executable)
@@ -488,7 +488,8 @@ class Keymanager {
                        $view->unlink($baseDir . $filePath);
                } else {
                        $localKeyPath = $view->getLocalFile($baseDir . $filePath);
-                       $matches = glob(preg_quote($localKeyPath) . '*.shareKey');
+                       $escapedPath = preg_replace('/(\*|\?|\[)/', '[$1]', $localKeyPath);
+                       $matches = glob($escapedPath . '*.shareKey');
                        foreach ($matches as $ma) {
                                $result = unlink($ma);
                                if (!$result) {
@@ -547,7 +548,10 @@ class Keymanager {
         */
        private static function recursiveDelShareKeys($dir, $userIds) {
                foreach ($userIds as $userId) {
-                       $matches = glob(preg_quote($dir) . '/*' . preg_quote('.' . $userId . '.shareKey'));
+                       $extension = '.' . $userId . '.shareKey';
+                       $escapedDir = preg_replace('/(\*|\?|\[)/', '[$1]', $dir);
+                       $escapedExtension = preg_replace('/(\*|\?|\[)/', '[$1]', $extension);
+                       $matches = glob($escapedDir . '/*' . $escapedExtension);
                }
                /** @var $matches array */
                foreach ($matches as $ma) {
@@ -556,7 +560,7 @@ class Keymanager {
                                        'Could not delete shareKey; does not exist: "' . $ma . '"', \OCP\Util::ERROR);
                        }
                }
-               $subdirs = $directories = glob(preg_quote($dir) . '/*', GLOB_ONLYDIR);
+               $subdirs = $directories = glob($escapedDir . '/*', GLOB_ONLYDIR);
                foreach ($subdirs as $subdir) {
                        self::recursiveDelShareKeys($subdir, $userIds);
                }