Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorBjörn Schießle <schiessle@owncloud.com>2013-06-25 18:50:10 +0400
committerBjörn Schießle <schiessle@owncloud.com>2013-07-05 18:13:22 +0400
commit5c5a8a0ebac2a130d655c690818f58048bfb3a12 (patch)
tree8bff0bd871043032eaed0b82f64a63ef84995f4d /apps
parent7bc153a87a6b603b3e96edf0de50243ad3f3a76f (diff)
only escape glob pattern
Diffstat (limited to 'apps')
-rw-r--r--apps/files_encryption/hooks/hooks.php3
-rwxr-xr-xapps/files_encryption/lib/keymanager.php10
2 files changed, 9 insertions, 4 deletions
diff --git a/apps/files_encryption/hooks/hooks.php b/apps/files_encryption/hooks/hooks.php
index 96f06b154f8..c26119b6c2e 100644
--- a/apps/files_encryption/hooks/hooks.php
+++ b/apps/files_encryption/hooks/hooks.php
@@ -497,7 +497,8 @@ class Hooks {
// handle share-keys
$localKeyPath = $view->getLocalFile($baseDir . 'share-keys/' . $params['oldpath']);
- $matches = glob(preg_quote($localKeyPath) . '*.shareKey');
+ $escapedPath = preg_replace('/(\*|\?|\[)/', '[$1]', $localKeyPath);
+ $matches = glob($escapedPath . '*.shareKey');
foreach ($matches as $src) {
$dst = \OC\Files\Filesystem::normalizePath(str_replace($params['oldpath'], $params['newpath'], $src));
diff --git a/apps/files_encryption/lib/keymanager.php b/apps/files_encryption/lib/keymanager.php
index 8de1d413642..da2ee380e89 100755
--- a/apps/files_encryption/lib/keymanager.php
+++ b/apps/files_encryption/lib/keymanager.php
@@ -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);
}