aboutsummaryrefslogtreecommitdiffstats
path: root/lib/filesystem.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/filesystem.php')
-rw-r--r--lib/filesystem.php43
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');