From acdce2b1e01f7c0a77b7e7949540e1b0ba94efd1 Mon Sep 17 00:00:00 2001 From: Tom Needham Date: Tue, 3 Apr 2012 22:31:34 +0000 Subject: [PATCH] Check blacklist before saving to filesystem --- lib/base.php | 3 +++ lib/filesystem.php | 13 +++++++++++++ 2 files changed, 16 insertions(+) diff --git a/lib/base.php b/lib/base.php index a4a94e8696..83dd0c98f4 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 12905d189f..b6909f5acd 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. */