diff options
author | Michael Gapczynski <mtgap@owncloud.com> | 2012-08-14 10:20:00 -0400 |
---|---|---|
committer | Michael Gapczynski <mtgap@owncloud.com> | 2012-08-14 10:22:13 -0400 |
commit | 4c7fd8cd0191871e48704f693f48554d4ee7a726 (patch) | |
tree | a66a930783de938deaa3d2362dcf779e5c2b45af /lib/filesystem.php | |
parent | 64ef1e21819979d7fdc406d2628bc175b16fe554 (diff) | |
parent | 62e4f55f721971dacd06649cecefe0487626aa75 (diff) | |
download | nextcloud-server-4c7fd8cd0191871e48704f693f48554d4ee7a726.tar.gz nextcloud-server-4c7fd8cd0191871e48704f693f48554d4ee7a726.zip |
Merge branch 'master' into share_api
Conflicts:
lib/group.php
lib/group/backend.php
lib/group/database.php
lib/group/interface.php
lib/public/user.php
lib/user.php
lib/user/backend.php
lib/user/database.php
lib/user/interface.php
Diffstat (limited to 'lib/filesystem.php')
-rw-r--r-- | lib/filesystem.php | 43 |
1 files changed, 39 insertions, 4 deletions
diff --git a/lib/filesystem.php b/lib/filesystem.php index 72d3711e9a2..2eeb044ddba 100644 --- a/lib/filesystem.php +++ b/lib/filesystem.php @@ -273,7 +273,12 @@ class OC_Filesystem{ */ static private function createStorage($class,$arguments){ if(class_exists($class)){ - return new $class($arguments); + try { + return new $class($arguments); + } catch (Exception $exception) { + OC_Log::write('core', $exception->getMessage(), OC_Log::ERROR); + return false; + } }else{ OC_Log::write('core','storage backend '.$class.' not found',OC_Log::ERROR); return false; @@ -363,13 +368,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; + } } } @@ -502,6 +515,28 @@ class OC_Filesystem{ } OC_Connector_Sabre_Node::removeETagPropertyForPath($path); } + + public static function normalizePath($path){ + //no windows style slashes + $path=str_replace('\\','/',$path); + //add leading slash + if($path[0]!=='/'){ + $path='/'.$path; + } + //remove trainling slash + if(strlen($path)>1 and substr($path,-1,1)==='/'){ + $path=substr($path,0,-1); + } + //remove duplicate slashes + while(strpos($path,'//')!==false){ + $path=str_replace('//','/',$path); + } + //normalize unicode if possible + if(class_exists('Normalizer')){ + $path=Normalizer::normalize($path); + } + return $path; + } } OC_Hook::connect('OC_Filesystem','post_write', 'OC_Filesystem','removeETagHook'); OC_Hook::connect('OC_Filesystem','post_delete','OC_Filesystem','removeETagHook'); |