From 12df81fe0ba5229cd9e80c86a960385efd48e459 Mon Sep 17 00:00:00 2001 From: Michael Gapczynski Date: Sat, 11 Aug 2012 11:04:04 -0400 Subject: [PATCH] Check blacklist when renaming files --- lib/base.php | 1 + lib/filesystem.php | 14 +++++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/base.php b/lib/base.php index 0e7e370cd6d..67f8e7702fc 100644 --- a/lib/base.php +++ b/lib/base.php @@ -434,6 +434,7 @@ class OC{ // Check for blacklisted files OC_Hook::connect('OC_Filesystem','write','OC_Filesystem','isBlacklisted'); + OC_Hook::connect('OC_Filesystem', 'rename', 'OC_Filesystem', 'isBlacklisted'); //make sure temporary files are cleaned up register_shutdown_function(array('OC_Helper','cleanTmp')); diff --git a/lib/filesystem.php b/lib/filesystem.php index 2c7df5daa3c..2a0c1cea93e 100644 --- a/lib/filesystem.php +++ b/lib/filesystem.php @@ -372,13 +372,21 @@ class OC_Filesystem{ /** * checks if a file is blacklsited for storage in the filesystem + * Listens to write and rename hooks * @param array $data from hook */ static public function isBlacklisted($data){ $blacklist = array('.htaccess'); - $filename = strtolower(basename($data['path'])); - if(in_array($filename,$blacklist)){ - $data['run'] = false; + if (isset($data['path'])) { + $path = $data['path']; + } else if (isset($data['newpath'])) { + $path = $data['newpath']; + } + if (isset($path)) { + $filename = strtolower(basename($path)); + if (in_array($filename, $blacklist)) { + $data['run'] = false; + } } } -- 2.39.5