From 366bad914d0bc14bfaa6376648c7412da6e74932 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Mon, 5 Sep 2011 10:25:28 +0000 Subject: [PATCH] * Filemanager/WebDAV: #?+ and chinese characters working now in filenames --- filemanager/inc/class.filemanager_ui.inc.php | 9 ++++++--- phpgwapi/inc/class.vfs_webdav_server.inc.php | 12 ++++++++++-- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/filemanager/inc/class.filemanager_ui.inc.php b/filemanager/inc/class.filemanager_ui.inc.php index 96ef1b252b..8e83738f80 100644 --- a/filemanager/inc/class.filemanager_ui.inc.php +++ b/filemanager/inc/class.filemanager_ui.inc.php @@ -915,15 +915,18 @@ function force_download(_action, _senders) { $msg .= $_GET['msg']; } - if (!($path = $_GET['path']) || !($stat = egw_vfs::lstat($path))) + if (!($path = str_replace(array('#','?'),array('%23','%3F'),$_GET['path'])) || // ?, # need to stay encoded! + // actions enclose pathes containing comma with " + ($path[0] == '"' && substr($path,-1) == '"' && !($path = substr(str_replace('""','"',$path),1,-1))) || + !($stat = egw_vfs::lstat($path))) { - $msg .= lang('File or directory not found!'); + $msg .= lang('File or directory not found!')." path='$path', stat=".array2string($stat); } else { $content = $stat; $content['name'] = egw_vfs::basename($path); - $content['dir'] = dirname($path); + $content['dir'] = egw_vfs::decodePath(egw_vfs::dirname($path)); $content['path'] = $path; $content['hsize'] = egw_vfs::hsize($stat['size']); $content['mime'] = egw_vfs::mime_content_type($path); diff --git a/phpgwapi/inc/class.vfs_webdav_server.inc.php b/phpgwapi/inc/class.vfs_webdav_server.inc.php index 4a2b7a7384..568bd3a946 100644 --- a/phpgwapi/inc/class.vfs_webdav_server.inc.php +++ b/phpgwapi/inc/class.vfs_webdav_server.inc.php @@ -251,6 +251,9 @@ class vfs_webdav_server extends HTTP_WebDAV_Server_Filesystem */ function fileinfo($path) { + // internally we require some url-encoding, as vfs_stream_wrapper uses URL's internally + $path = str_replace(array('#','?'),array('%23','%3F'),$path); + //error_log(__METHOD__."($path)"); // map URI path to filesystem path $fspath = $this->base . $path; @@ -259,10 +262,15 @@ class vfs_webdav_server extends HTTP_WebDAV_Server_Filesystem $info = array(); // TODO remove slash append code when base class is able to do it itself $info['path'] = is_dir($fspath) ? $this->_slashify($path) : $path; + + // remove all urlencoding we need internally in EGw, HTTP_WebDAV_Server will add it's own! + // rawurldecode does NOT touch + + $info['path'] = rawurldecode($info['path']); + $info['props'] = array(); // no special beautified displayname here ... - $info['props'][] = HTTP_WebDAV_Server::mkprop ('displayname', egw_vfs::basename(self::_unslashify($path))); + $info['props'][] = HTTP_WebDAV_Server::mkprop ('displayname', egw_vfs::basename(self::_unslashify($info['path']))); // creation and modification time $info['props'][] = HTTP_WebDAV_Server::mkprop ('creationdate', filectime($fspath)); @@ -304,7 +312,7 @@ class vfs_webdav_server extends HTTP_WebDAV_Server_Filesystem */ // ToDo: etag from inode and modification time - //error_log(__METHOD__."($path) info=".print_r($info,true)); + //error_log(__METHOD__."($path) info=".array2string($info)); return $info; }