From 7cbf2143cd61181b67e0c76fb6f182dd913a44ca Mon Sep 17 00:00:00 2001 From: Sergey Spivak Date: Mon, 17 Oct 2016 18:13:30 +0400 Subject: [PATCH 1/2] Delete trailing whitespaces on rename and mkdir Whitespace at end of filename cause errors while accessing those files and dirs via WebDAV (e.g. Nautilus, Caja, etc). This patch tries to avoid creation of such nodes. --- core/src/plugins/access.fs/FsAccessDriver.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/src/plugins/access.fs/FsAccessDriver.php b/core/src/plugins/access.fs/FsAccessDriver.php index b31934392e..6d0741c95a 100644 --- a/core/src/plugins/access.fs/FsAccessDriver.php +++ b/core/src/plugins/access.fs/FsAccessDriver.php @@ -1114,6 +1114,7 @@ public function switchAction(ServerRequestInterface &$request, ResponseInterface $this->filterUserSelectionToHidden($ctx, [$destNode->getLabel()]); }else if(isSet($httpVars["filename_new"])){ $filename_new = InputFilter::decodeSecureMagic($httpVars["filename_new"]); + $filename_new = rtrim($filename_new); $this->filterUserSelectionToHidden($ctx, [$filename_new]); } $renamedNode = $this->rename($originalNode, $destNode, $filename_new); @@ -1148,6 +1149,7 @@ public function switchAction(ServerRequestInterface &$request, ResponseInterface $parentDir = PathUtils::forwardSlashDirname($newDirPath); $basename = PathUtils::forwardSlashBasename($newDirPath); $basename = substr($basename, 0, $max_length); + $basename = rtrim($basename); $this->filterUserSelectionToHidden($ctx, [$basename]); $parentNode = $selection->nodeForPath($parentDir); try{ @@ -2545,4 +2547,4 @@ public function makeSharedRepositoryOptions(ContextInterface $ctx, $httpVars) } -} \ No newline at end of file +} From c337ff0fc51938652abb36d28625e18941cc6612 Mon Sep 17 00:00:00 2001 From: Sergey Spivak Date: Tue, 18 Oct 2016 10:47:15 +0400 Subject: [PATCH 2/2] Rtrim whitespaces in stored filenames of zip archives Windows can't handle files and dirs with trailing whitespace in name --- core/src/plugins/access.fs/FsAccessDriver.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/core/src/plugins/access.fs/FsAccessDriver.php b/core/src/plugins/access.fs/FsAccessDriver.php index 6d0741c95a..189bf2258b 100644 --- a/core/src/plugins/access.fs/FsAccessDriver.php +++ b/core/src/plugins/access.fs/FsAccessDriver.php @@ -2401,6 +2401,11 @@ public function makeZip (UserSelection $selection, $dest, $basedir, $taskId = nu TaskService::getInstance()->updateTaskStatus($taskId, Task::STATUS_RUNNING, "Adding ".$header["stored_filename"]." to archive"); } $search = $header["filename"]; + $split = explode("/", $header["stored_filename"]); + foreach ($split as &$value) { + $value = rtrim($value); + } + $header["stored_filename"] = join("/", $split); if(!empty($zipEncoding)){ $test = iconv($fsEncoding, $zipEncoding, $header["stored_filename"]); if($test !== false){