From: Tom Needham Date: Tue, 3 Apr 2012 22:31:34 +0000 (+0000) Subject: Check blacklist before saving to filesystem X-Git-Tag: v4.0.0beta~381^2~12 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=acdce2b1e01f7c0a77b7e7949540e1b0ba94efd1;p=nextcloud-server.git Check blacklist before saving to filesystem --- diff --git a/lib/base.php b/lib/base.php index a4a94e86968..83dd0c98f45 100644 --- a/lib/base.php +++ b/lib/base.php @@ -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')); diff --git a/lib/filesystem.php b/lib/filesystem.php index 12905d189f9..b6909f5acdf 100644 --- a/lib/filesystem.php +++ b/lib/filesystem.php @@ -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. */