diff options
author | Arthur Schiwon <blizzz@owncloud.com> | 2012-11-04 19:58:48 +0100 |
---|---|---|
committer | Arthur Schiwon <blizzz@owncloud.com> | 2012-11-04 19:58:48 +0100 |
commit | 00bb246a0d90ddbcc1016fdedb5cf629bfbca70a (patch) | |
tree | f5d69cf10ef3fd157a21990a38515c03b74035a1 /lib/filesystem.php | |
parent | df8c67721df1358eab7aa5794ef223a5bc8f0b59 (diff) | |
parent | 8ac3849a95bd6a733cce9134bab4bf38c5c0fadd (diff) | |
download | nextcloud-server-00bb246a0d90ddbcc1016fdedb5cf629bfbca70a.tar.gz nextcloud-server-00bb246a0d90ddbcc1016fdedb5cf629bfbca70a.zip |
merge from master
Diffstat (limited to 'lib/filesystem.php')
-rw-r--r-- | lib/filesystem.php | 52 |
1 files changed, 29 insertions, 23 deletions
diff --git a/lib/filesystem.php b/lib/filesystem.php index 3b6772c9849..aeafb149395 100644 --- a/lib/filesystem.php +++ b/lib/filesystem.php @@ -35,10 +35,10 @@ * post_create(path) * delete(path, &run) * post_delete(path) - * rename(oldpath,newpath, &run) - * post_rename(oldpath,newpath) - * copy(oldpath,newpath, &run) (if the newpath doesn't exists yes, copy, create and write will be emited in that order) - * post_rename(oldpath,newpath) + * rename(oldpath, newpath, &run) + * post_rename(oldpath, newpath) + * copy(oldpath, newpath, &run) (if the newpath doesn't exists yes, copy, create and write will be emited in that order) + * post_rename(oldpath, newpath) * * the &run parameter can be set to false to prevent the operation from occuring */ @@ -246,7 +246,7 @@ class OC_Filesystem{ }
$mtime=filemtime(OC::$SERVERROOT.'/config/mount.php');
- $previousMTime=OC_Appconfig::getValue('files','mountconfigmtime',0);
+ $previousMTime=OC_Appconfig::getValue('files','mountconfigmtime', 0);
if($mtime>$previousMTime) {//mount config has changed, filecache needs to be updated
OC_FileCache::triggerUpdate();
OC_Appconfig::setValue('files', 'mountconfigmtime', $mtime);
@@ -303,7 +303,7 @@ class OC_Filesystem{ * @param array arguments * @return OC_Filestorage */ - static private function createStorage($class,$arguments) { + static private function createStorage($class, $arguments) { if(class_exists($class)) { try { return new $class($arguments); @@ -312,7 +312,7 @@ class OC_Filesystem{ return false; } }else{ - OC_Log::write('core','storage backend '.$class.' not found',OC_Log::ERROR); + OC_Log::write('core','storage backend '.$class.' not found', OC_Log::ERROR); return false; } } @@ -349,14 +349,14 @@ class OC_Filesystem{ * @param OC_Filestorage storage * @param string mountpoint */ - static public function mount($class,$arguments,$mountpoint) { + static public function mount($class, $arguments, $mountpoint) { if($mountpoint[0]!='/') { $mountpoint='/'.$mountpoint; } if(substr($mountpoint, -1)!=='/') { $mountpoint=$mountpoint.'/'; } - self::$mounts[$mountpoint]=array('class'=>$class,'arguments'=>$arguments); + self::$mounts[$mountpoint]=array('class'=>$class, 'arguments'=>$arguments); } /** @@ -396,12 +396,16 @@ class OC_Filesystem{ * @return bool */ static public function isValidPath($path) { + $path = self::normalizePath($path); if(!$path || $path[0]!=='/') { $path='/'.$path; } if(strstr($path, '/../') || strrchr($path, '/') === '/..' ) { return false; } + if(self::isFileBlacklisted($path)) { + return false; + } return true; } @@ -411,20 +415,22 @@ class OC_Filesystem{ * @param array $data from hook */ static public function isBlacklisted($data) { - $blacklist = array('.htaccess'); 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; - } + $data['run'] = !self::isFileBlacklisted($path); } } + static public function isFileBlacklisted($path) { + $blacklist = array('.htaccess'); + $filename = strtolower(basename($path)); + return in_array($filename, $blacklist); + } + /** * following functions are equivilent to their php buildin equivilents for arguments/return values. */ @@ -500,32 +506,32 @@ class OC_Filesystem{ static public function file_get_contents($path) { return self::$defaultInstance->file_get_contents($path); } - static public function file_put_contents($path,$data) { + static public function file_put_contents($path, $data) { return self::$defaultInstance->file_put_contents($path, $data); } static public function unlink($path) { return self::$defaultInstance->unlink($path); } - static public function rename($path1,$path2) { + static public function rename($path1, $path2) { return self::$defaultInstance->rename($path1, $path2); } - static public function copy($path1,$path2) { + static public function copy($path1, $path2) { return self::$defaultInstance->copy($path1, $path2); } - static public function fopen($path,$mode) { + static public function fopen($path, $mode) { return self::$defaultInstance->fopen($path, $mode); } static public function toTmpFile($path) { return self::$defaultInstance->toTmpFile($path); } - static public function fromTmpFile($tmpFile,$path) { + static public function fromTmpFile($tmpFile, $path) { return self::$defaultInstance->fromTmpFile($tmpFile, $path); } static public function getMimeType($path) { return self::$defaultInstance->getMimeType($path); } - static public function hash($type,$path, $raw = false) { + static public function hash($type, $path, $raw = false) { return self::$defaultInstance->hash($type, $path, $raw); } @@ -542,7 +548,7 @@ class OC_Filesystem{ * @param int $time * @return bool */ - static public function hasUpdated($path,$time) { + static public function hasUpdated($path, $time) { return self::$defaultInstance->hasUpdated($path, $time); } @@ -569,7 +575,7 @@ class OC_Filesystem{ * @param bool $stripTrailingSlash * @return string */ - public static function normalizePath($path,$stripTrailingSlash=true) { + public static function normalizePath($path, $stripTrailingSlash=true) { if($path=='') { return '/'; } @@ -584,7 +590,7 @@ class OC_Filesystem{ $path=substr($path, 0, -1); } //remove duplicate slashes - while(strpos($path,'//')!==false) { + while(strpos($path, '//')!==false) { $path=str_replace('//', '/', $path); } //normalize unicode if possible |