]> source.dussan.org Git - nextcloud-server.git/commitdiff
only escape glob pattern
authorBjörn Schießle <schiessle@owncloud.com>
Fri, 14 Jun 2013 13:07:06 +0000 (15:07 +0200)
committerBjörn Schießle <schiessle@owncloud.com>
Fri, 14 Jun 2013 13:07:06 +0000 (15:07 +0200)
apps/files_trashbin/lib/trash.php
apps/files_versions/lib/versions.php

index 2d1830a38f1b4a8e10e575dab4cfc2b5222fdb49..e06e959f8ebd08c564d061ca8b4859a38dac38bb 100644 (file)
@@ -193,10 +193,11 @@ class Trashbin {
                                $rootView->rename($sharekeys, $user.'/files_trashbin/share-keys/' . $filename . '.d' . $timestamp);
                        } else {
                 // get local path to share-keys
-                $localShareKeysPath = $rootView->getLocalFile($sharekeys);
+                               $localShareKeysPath = $rootView->getLocalFile($sharekeys);
+                               $escapedLocalShareKeysPath = preg_replace('/(\*|\?|\[)/', '[$1]', $localShareKeysPath);
 
                 // handle share-keys
-                $matches = glob(preg_quote($localShareKeysPath).'*.shareKey');
+                $matches = glob($escapedLocalShareKeysPath.'*.shareKey');
                 foreach ($matches as $src) {
                     // get source file parts
                     $pathinfo = pathinfo($src);
@@ -737,14 +738,15 @@ class Trashbin {
         */
        private static function getVersionsFromTrash($filename, $timestamp) {
                $view = new \OC\Files\View('/'.\OCP\User::getUser().'/files_trashbin/versions');
-               $versionsName = $view->getLocalFile($filename);
+               $versionsName = $view->getLocalFile($filename).'.v';
+               $escapedVersionsName = preg_replace('/(\*|\?|\[)/', '[$1]', $versionsName);
                $versions = array();
                if ($timestamp ) {
                        // fetch for old versions
-                       $matches = glob( $versionsName.'.v*.d'.$timestamp );
+                       $matches = glob( $escapedVersionsName.'*.d'.$timestamp );
                        $offset = -strlen($timestamp)-2;
                } else {
-                       $matches = glob( $versionsName.'.v*' );
+                       $matches = glob( $escapedVersionsName.'*' );
                }
 
                foreach( $matches as $ma ) {
index 4beb9e0fe5cc18929f4255871836c3de4d009ab8..757926cd77a64aac13911ff4623f7b5eef4e7e92 100644 (file)
@@ -241,11 +241,12 @@ class Storage {
        public static function getVersions($uid, $filename, $count = 0 ) {
                if( \OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true' ) {
                        $versions_fileview = new \OC\Files\View('/' . $uid . '/files_versions');
-                       $versionsName = $versions_fileview->getLocalFile($filename);
-                       
+                       $versionsName = \OC_Filesystem::normalizePath($versions_fileview->getLocalFile($filename).'.v');
+                       $escapedVersionName = preg_replace('/(\*|\?|\[)/', '[$1]', $versionsName);
+
                        $versions = array();
                        // fetch for old versions
-                       $matches = glob(preg_quote($versionsName).'.v*' );
+                       $matches = glob($escapedVersionName.'*');
 
                        if ( !$matches ) {
                                return $versions;