]> source.dussan.org Git - nextcloud-server.git/commitdiff
Check blacklist before saving to filesystem
authorTom Needham <needham.thomas@gmail.com>
Tue, 3 Apr 2012 22:31:34 +0000 (22:31 +0000)
committerTom Needham <needham.thomas@gmail.com>
Tue, 3 Apr 2012 22:31:34 +0000 (22:31 +0000)
lib/base.php
lib/filesystem.php

index a4a94e869686a3a52656a39d0ea722fa56d95a66..83dd0c98f45cdeef97421df94ff15e6657bf4a2e 100644 (file)
@@ -365,6 +365,9 @@ class OC{
                                OC_App::loadApps();
                        }
                }
+               
+               // Check for blacklisted files
+               OC_Hook::connect('OC_Filesystem','write','OC_Filesystem','isBlacklisted');
 
                //make sure temporary files are cleaned up
                register_shutdown_function(array('OC_Helper','cleanTmp'));
index 12905d189f947c2e878466695df9cd6b3e886cfb..b6909f5acdf77d01d2a93a9d3d7791171a53afe6 100644 (file)
@@ -298,6 +298,19 @@ class OC_Filesystem{
                }
                return true;
        }
+       
+       /**
+        * checks if a file is blacklsited for storage in the filesystem
+        * @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;   
+               }
+       }
+       
        /**
         * following functions are equivilent to their php buildin equivilents for arguments/return values.
         */