Merge pull request #3727 from owncloud/fix_glob_escaping
only escape glob pattern
This commit is contained in:
commit
0089437c25
2
3rdparty
2
3rdparty
|
@ -1 +1 @@
|
||||||
Subproject commit 3ef9f738a9107879dddc7d97842cf4d2198fae4c
|
Subproject commit e312294ef62873df2b8c02e774f9dfe1b7fbc38d
|
|
@ -24,6 +24,7 @@ namespace OCA\Files_Trashbin;
|
||||||
|
|
||||||
class Trashbin {
|
class Trashbin {
|
||||||
// how long do we keep files in the trash bin if no other value is defined in the config file (unit: days)
|
// how long do we keep files in the trash bin if no other value is defined in the config file (unit: days)
|
||||||
|
|
||||||
const DEFAULT_RETENTION_OBLIGATION = 180;
|
const DEFAULT_RETENTION_OBLIGATION = 180;
|
||||||
|
|
||||||
// unit: percentage; 50% of available disk space/quota
|
// unit: percentage; 50% of available disk space/quota
|
||||||
|
@ -96,13 +97,11 @@ class Trashbin {
|
||||||
\OC_Log::write('files_trashbin', 'trash bin database couldn\'t be updated', \OC_log::ERROR);
|
\OC_Log::write('files_trashbin', 'trash bin database couldn\'t be updated', \OC_log::ERROR);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
\OCP\Util::emitHook('\OCA\Files_Trashbin\Trashbin', 'post_moveToTrash',
|
\OCP\Util::emitHook('\OCA\Files_Trashbin\Trashbin', 'post_moveToTrash', array('filePath' => \OC\Files\Filesystem::normalizePath($file_path),
|
||||||
array('filePath' => \OC\Files\Filesystem::normalizePath($file_path),
|
|
||||||
'trashPath' => \OC\Files\Filesystem::normalizePath($filename . '.d' . $timestamp)));
|
'trashPath' => \OC\Files\Filesystem::normalizePath($filename . '.d' . $timestamp)));
|
||||||
|
|
||||||
$trashbinSize += self::retainVersions($view, $file_path, $filename, $timestamp);
|
$trashbinSize += self::retainVersions($view, $file_path, $filename, $timestamp);
|
||||||
$trashbinSize += self::retainEncryptionKeys($view, $file_path, $filename, $timestamp);
|
$trashbinSize += self::retainEncryptionKeys($view, $file_path, $filename, $timestamp);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
\OC_Log::write('files_trashbin', 'Couldn\'t move ' . $file_path . ' to the trash bin', \OC_log::ERROR);
|
\OC_Log::write('files_trashbin', 'Couldn\'t move ' . $file_path . ' to the trash bin', \OC_log::ERROR);
|
||||||
}
|
}
|
||||||
|
@ -110,7 +109,6 @@ class Trashbin {
|
||||||
$trashbinSize -= self::expire($trashbinSize);
|
$trashbinSize -= self::expire($trashbinSize);
|
||||||
|
|
||||||
self::setTrashbinSize($user, $trashbinSize);
|
self::setTrashbinSize($user, $trashbinSize);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -201,9 +199,10 @@ class Trashbin {
|
||||||
} else {
|
} else {
|
||||||
// get local path to share-keys
|
// get local path to share-keys
|
||||||
$localShareKeysPath = $rootView->getLocalFile($sharekeys);
|
$localShareKeysPath = $rootView->getLocalFile($sharekeys);
|
||||||
|
$escapedLocalShareKeysPath = preg_replace('/(\*|\?|\[)/', '[$1]', $localShareKeysPath);
|
||||||
|
|
||||||
// handle share-keys
|
// handle share-keys
|
||||||
$matches = glob(preg_quote($localShareKeysPath).'*.shareKey');
|
$matches = glob($escapedLocalShareKeysPath . '*.shareKey');
|
||||||
foreach ($matches as $src) {
|
foreach ($matches as $src) {
|
||||||
// get source file parts
|
// get source file parts
|
||||||
$pathinfo = pathinfo($src);
|
$pathinfo = pathinfo($src);
|
||||||
|
@ -228,7 +227,6 @@ class Trashbin {
|
||||||
unlink($src);
|
unlink($src);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// enable proxy
|
// enable proxy
|
||||||
|
@ -299,8 +297,7 @@ class Trashbin {
|
||||||
$view->chroot('/' . $user . '/files');
|
$view->chroot('/' . $user . '/files');
|
||||||
$view->touch('/' . $location . '/' . $filename . $ext, $mtime);
|
$view->touch('/' . $location . '/' . $filename . $ext, $mtime);
|
||||||
$view->chroot($fakeRoot);
|
$view->chroot($fakeRoot);
|
||||||
\OCP\Util::emitHook('\OCA\Files_Trashbin\Trashbin', 'post_restore',
|
\OCP\Util::emitHook('\OCA\Files_Trashbin\Trashbin', 'post_restore', array('filePath' => \OC\Files\Filesystem::normalizePath('/' . $location . '/' . $filename . $ext),
|
||||||
array('filePath' => \OC\Files\Filesystem::normalizePath('/'.$location.'/'.$filename.$ext),
|
|
||||||
'trashPath' => \OC\Files\Filesystem::normalizePath($file)));
|
'trashPath' => \OC\Files\Filesystem::normalizePath($file)));
|
||||||
if ($view->is_dir($target . $ext)) {
|
if ($view->is_dir($target . $ext)) {
|
||||||
$trashbinSize -= self::calculateSize(new \OC\Files\View('/' . $user . '/' . $target . $ext));
|
$trashbinSize -= self::calculateSize(new \OC\Files\View('/' . $user . '/' . $target . $ext));
|
||||||
|
@ -383,7 +380,6 @@ class Trashbin {
|
||||||
return $size;
|
return $size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief restore encryption keys from trash bin
|
* @brief restore encryption keys from trash bin
|
||||||
*
|
*
|
||||||
|
@ -444,7 +440,6 @@ class Trashbin {
|
||||||
}
|
}
|
||||||
$size += self::calculateSize(new \OC\Files\View($sharekey));
|
$size += self::calculateSize(new \OC\Files\View($sharekey));
|
||||||
$rootView->rename($sharekey, $owner . '/files_encryption/share-keys/' . $ownerPath);
|
$rootView->rename($sharekey, $owner . '/files_encryption/share-keys/' . $ownerPath);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// handle keyfiles
|
// handle keyfiles
|
||||||
$size += $rootView->filesize($keyfile);
|
$size += $rootView->filesize($keyfile);
|
||||||
|
@ -672,8 +667,7 @@ class Trashbin {
|
||||||
$query = \OC_DB::prepare('SELECT `location`,`type`,`id`,`timestamp` FROM `*PREFIX*files_trash` WHERE `user`=?');
|
$query = \OC_DB::prepare('SELECT `location`,`type`,`id`,`timestamp` FROM `*PREFIX*files_trash` WHERE `user`=?');
|
||||||
$result = $query->execute(array($user))->fetchAll();
|
$result = $query->execute(array($user))->fetchAll();
|
||||||
|
|
||||||
$retention_obligation = \OC_Config::getValue('trashbin_retention_obligation',
|
$retention_obligation = \OC_Config::getValue('trashbin_retention_obligation', self::DEFAULT_RETENTION_OBLIGATION);
|
||||||
self::DEFAULT_RETENTION_OBLIGATION);
|
|
||||||
|
|
||||||
$limit = time() - ($retention_obligation * 86400);
|
$limit = time() - ($retention_obligation * 86400);
|
||||||
|
|
||||||
|
@ -700,8 +694,6 @@ class Trashbin {
|
||||||
$size += $tmp;
|
$size += $tmp;
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $size;
|
return $size;
|
||||||
|
@ -744,14 +736,15 @@ class Trashbin {
|
||||||
*/
|
*/
|
||||||
private static function getVersionsFromTrash($filename, $timestamp) {
|
private static function getVersionsFromTrash($filename, $timestamp) {
|
||||||
$view = new \OC\Files\View('/' . \OCP\User::getUser() . '/files_trashbin/versions');
|
$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();
|
$versions = array();
|
||||||
if ($timestamp) {
|
if ($timestamp) {
|
||||||
// fetch for old versions
|
// fetch for old versions
|
||||||
$matches = glob( $versionsName.'.v*.d'.$timestamp );
|
$matches = glob($escapedVersionsName . '*.d' . $timestamp);
|
||||||
$offset = -strlen($timestamp) - 2;
|
$offset = -strlen($timestamp) - 2;
|
||||||
} else {
|
} else {
|
||||||
$matches = glob( $versionsName.'.v*' );
|
$matches = glob($escapedVersionsName . '*');
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($matches as $ma) {
|
foreach ($matches as $ma) {
|
||||||
|
@ -797,8 +790,7 @@ class Trashbin {
|
||||||
if (!file_exists($root)) {
|
if (!file_exists($root)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
$iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($root),
|
$iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($root), \RecursiveIteratorIterator::CHILD_FIRST);
|
||||||
\RecursiveIteratorIterator::CHILD_FIRST);
|
|
||||||
$size = 0;
|
$size = 0;
|
||||||
|
|
||||||
foreach ($iterator as $path) {
|
foreach ($iterator as $path) {
|
||||||
|
@ -850,4 +842,5 @@ class Trashbin {
|
||||||
//Listen to delete user signal
|
//Listen to delete user signal
|
||||||
\OCP\Util::connectHook('OC_User', 'pre_deleteUser', "OCA\Files_Trashbin\Hooks", "deleteUser_hook");
|
\OCP\Util::connectHook('OC_User', 'pre_deleteUser', "OCA\Files_Trashbin\Hooks", "deleteUser_hook");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -241,11 +241,12 @@ class Storage {
|
||||||
public static function getVersions($uid, $filename, $count = 0 ) {
|
public static function getVersions($uid, $filename, $count = 0 ) {
|
||||||
if( \OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true' ) {
|
if( \OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true' ) {
|
||||||
$versions_fileview = new \OC\Files\View('/' . $uid . '/files_versions');
|
$versions_fileview = new \OC\Files\View('/' . $uid . '/files_versions');
|
||||||
$versionsName = $versions_fileview->getLocalFile($filename);
|
$versionsName = $versions_fileview->getLocalFile($filename).'.v';
|
||||||
|
$escapedVersionName = preg_replace('/(\*|\?|\[)/', '[$1]', $versionsName);
|
||||||
|
|
||||||
$versions = array();
|
$versions = array();
|
||||||
// fetch for old versions
|
// fetch for old versions
|
||||||
$matches = glob(preg_quote($versionsName).'.v*' );
|
$matches = glob($escapedVersionName.'*');
|
||||||
|
|
||||||
if ( !$matches ) {
|
if ( !$matches ) {
|
||||||
return $versions;
|
return $versions;
|
||||||
|
|
Loading…
Reference in New Issue