Check blacklist when renaming files

This commit is contained in:
Michael Gapczynski 2012-08-11 11:04:04 -04:00 committed by Jörn Friedrich Dreyer
parent 5cb2d58c9f
commit 12df81fe0b
2 changed files with 12 additions and 3 deletions

View 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'));

View 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;
}
}
}