]> source.dussan.org Git - nextcloud-server.git/commitdiff
Check blacklist when renaming files
authorMichael Gapczynski <mtgap@owncloud.com>
Sat, 11 Aug 2012 15:04:04 +0000 (11:04 -0400)
committerJörn Friedrich Dreyer <jfd@butonic.de>
Fri, 24 Aug 2012 13:00:52 +0000 (15:00 +0200)
lib/base.php
lib/filesystem.php

index 0e7e370cd6d72b646375612326b284e1f8513ad1..67f8e7702fc3111b54c6bf3710ce901341e0305e 100644 (file)
@@ -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'));
index 2c7df5daa3cf72dd298af1b77ec5e0cded9b3248..2a0c1cea93e64e8fab648eb8b07f3e2e758c2596 100644 (file)
@@ -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;
+                       }
                }
        }