aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjörn Schießle <schiessle@owncloud.com>2013-06-14 15:07:06 +0200
committerBjörn Schießle <schiessle@owncloud.com>2013-06-17 15:39:43 +0200
commit1fead354b2a4b83a5dd34476e686b1bc3e2de3ad (patch)
tree4dd9e9141e5fc5decf387995db3427a677fdf46d
parent52d1797b304d1a43b406ea6351c66805476be6b1 (diff)
downloadnextcloud-server-1fead354b2a4b83a5dd34476e686b1bc3e2de3ad.tar.gz
nextcloud-server-1fead354b2a4b83a5dd34476e686b1bc3e2de3ad.zip
only escape glob pattern
Conflicts: apps/files_trashbin/lib/trash.php
-rw-r--r--apps/files_trashbin/lib/trash.php26
-rw-r--r--apps/files_versions/lib/versions.php7
2 files changed, 19 insertions, 14 deletions
diff --git a/apps/files_trashbin/lib/trash.php b/apps/files_trashbin/lib/trash.php
index 29e750ef89f..6a4b832802c 100644
--- a/apps/files_trashbin/lib/trash.php
+++ b/apps/files_trashbin/lib/trash.php
@@ -191,14 +191,16 @@ class Trashbin {
$size += self::calculateSize(new \OC\Files\View($sharekeys));
$rootView->rename($sharekeys, $user . '/files_trashbin/share-keys/' . $filename . '.d' . $timestamp);
} else {
- // get local path to share-keys
+
+ // get local path to share-keys
$localShareKeysPath = $rootView->getLocalFile($sharekeys);
+ $escapedLocalShareKeysPath = preg_replace('/(\*|\?|\[)/', '[$1]', $localShareKeysPath);
- // handle share-keys
- $matches = glob(preg_quote($localShareKeysPath) . '*.shareKey');
- foreach ($matches as $src) {
- // get source file parts
- $pathinfo = pathinfo($src);
+ // handle share-keys
+ $matches = glob($escapedLocalShareKeysPath.'*.shareKey');
+ foreach ($matches as $src) {
+ // get source file parts
+ $pathinfo = pathinfo($src);
// we only want to keep the owners key so we can access the private key
$ownerShareKey = $filename . '.' . $user . '.shareKey';
@@ -724,15 +726,17 @@ class Trashbin {
* @param $timestamp timestamp when the file was deleted
*/
private static function getVersionsFromTrash($filename, $timestamp) {
- $view = new \OC\Files\View('/' . \OCP\User::getUser() . '/files_trashbin/versions');
- $versionsName = $view->getLocalFile($filename);
+
+ $view = new \OC\Files\View('/'.\OCP\User::getUser().'/files_trashbin/versions');
+ $versionsName = $view->getLocalFile($filename).'.v';
+ $escapedVersionsName = preg_replace('/(\*|\?|\[)/', '[$1]', $versionsName);
$versions = array();
if ($timestamp) {
// fetch for old versions
- $matches = glob($versionsName . '.v*.d' . $timestamp);
- $offset = -strlen($timestamp) - 2;
+ $matches = glob( $escapedVersionsName.'*.d'.$timestamp );
+ $offset = -strlen($timestamp)-2;
} else {
- $matches = glob($versionsName . '.v*');
+ $matches = glob( $escapedVersionsName.'*' );
}
foreach ($matches as $ma) {
diff --git a/apps/files_versions/lib/versions.php b/apps/files_versions/lib/versions.php
index 4beb9e0fe5c..757926cd77a 100644
--- a/apps/files_versions/lib/versions.php
+++ b/apps/files_versions/lib/versions.php
@@ -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;