summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorBjörn Schießle <schiessle@owncloud.com>2013-07-05 14:58:33 +0200
committerBjörn Schießle <schiessle@owncloud.com>2013-07-05 16:03:20 +0200
commit9575c2f37c39ae0799c3b8faec4d7902d17e6832 (patch)
tree264b451f93e37eaa0b6ba45627f2201e13bbb104 /apps
parentec6350079f5eab706bb4567654c99c6f800a4f49 (diff)
downloadnextcloud-server-9575c2f37c39ae0799c3b8faec4d7902d17e6832.tar.gz
nextcloud-server-9575c2f37c39ae0799c3b8faec4d7902d17e6832.zip
added helper function to escape glob pattern
Conflicts: apps/files_encryption/lib/helper.php
Diffstat (limited to 'apps')
-rw-r--r--apps/files_encryption/hooks/hooks.php2
-rwxr-xr-xapps/files_encryption/lib/helper.php12
-rwxr-xr-xapps/files_encryption/lib/keymanager.php6
3 files changed, 15 insertions, 5 deletions
diff --git a/apps/files_encryption/hooks/hooks.php b/apps/files_encryption/hooks/hooks.php
index c26119b6c2e..b2a17f6bca5 100644
--- a/apps/files_encryption/hooks/hooks.php
+++ b/apps/files_encryption/hooks/hooks.php
@@ -497,7 +497,7 @@ class Hooks {
// handle share-keys
$localKeyPath = $view->getLocalFile($baseDir . 'share-keys/' . $params['oldpath']);
- $escapedPath = preg_replace('/(\*|\?|\[)/', '[$1]', $localKeyPath);
+ $escapedPath = Helper::escapeGlobPattern($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/helper.php b/apps/files_encryption/lib/helper.php
index 31cf48a0393..1b9637c1b9a 100755
--- a/apps/files_encryption/lib/helper.php
+++ b/apps/files_encryption/lib/helper.php
@@ -218,7 +218,6 @@ class Helper {
exit();
}
-
/**
* check requirements for encryption app.
* @return bool true if requirements are met
@@ -234,3 +233,14 @@ class Helper {
return (bool) $result;
}
}
+
+ /**
+ * @brief glob uses different pattern than regular expressions, escape glob pattern only
+ * @param unescaped path
+ * @return escaped path
+ */
+ public static function escapeGlobPattern($path) {
+ return preg_replace('/(\*|\?|\[)/', '[$1]', $path);
+ }
+}
+
diff --git a/apps/files_encryption/lib/keymanager.php b/apps/files_encryption/lib/keymanager.php
index da2ee380e89..b2fd650f18d 100755
--- a/apps/files_encryption/lib/keymanager.php
+++ b/apps/files_encryption/lib/keymanager.php
@@ -488,7 +488,7 @@ class Keymanager {
$view->unlink($baseDir . $filePath);
} else {
$localKeyPath = $view->getLocalFile($baseDir . $filePath);
- $escapedPath = preg_replace('/(\*|\?|\[)/', '[$1]', $localKeyPath);
+ $escapedPath = Helper::escapeGlobPattern($localKeyPath);
$matches = glob($escapedPath . '*.shareKey');
foreach ($matches as $ma) {
$result = unlink($ma);
@@ -549,8 +549,8 @@ class Keymanager {
private static function recursiveDelShareKeys($dir, $userIds) {
foreach ($userIds as $userId) {
$extension = '.' . $userId . '.shareKey';
- $escapedDir = preg_replace('/(\*|\?|\[)/', '[$1]', $dir);
- $escapedExtension = preg_replace('/(\*|\?|\[)/', '[$1]', $extension);
+ $escapedDir = Helper::escapeGlobPattern($dir);
+ $escapedExtension = Helper::escapeGlobPattern($extension);
$matches = glob($escapedDir . '/*' . $escapedExtension);
}
/** @var $matches array */