]> source.dussan.org Git - nextcloud-server.git/commitdiff
filter files containing a hash in the path for ftp storages 21789/head
authorRobin Appelman <robin@icewind.nl>
Fri, 10 Jul 2020 12:18:40 +0000 (14:18 +0200)
committerRobin Appelman <robin@icewind.nl>
Fri, 10 Jul 2020 12:18:40 +0000 (14:18 +0200)
the php ftp streamwrapper doesn't handle hashes correctly and will break when it tries to enter a path containing a hash.

By filtering out paths containing a hash we can at least stop the external storage from breaking completely

Signed-off-by: Robin Appelman <robin@icewind.nl>
apps/files_external/lib/Lib/Storage/FTP.php
lib/private/Files/Storage/Common.php

index 2af145ad4a23790c6b154ffb7e7eaffa687cb084..d9e5e2a0d5af57c8a2532fbaaa1565c3d92ee5d8 100644 (file)
@@ -35,6 +35,7 @@
 namespace OCA\Files_External\Lib\Storage;
 
 use Icewind\Streams\CallbackWrapper;
+use Icewind\Streams\IteratorDirectory;
 use Icewind\Streams\RetryWrapper;
 
 class FTP extends StreamWrapper {
@@ -136,6 +137,22 @@ class FTP extends StreamWrapper {
                return false;
        }
 
+       public function opendir($path) {
+               $dh = parent::opendir($path);
+               if (is_resource($dh)) {
+                       $files = [];
+                       while (($file = readdir($dh)) !== false) {
+                               if ($file != '.' && $file != '..' && strpos($file, '#') === false) {
+                                       $files[] = $file;
+                               }
+                       }
+                       return IteratorDirectory::wrap($files);
+               } else {
+                       return false;
+               }
+       }
+
+
        public function writeBack($tmpFile, $path) {
                $this->uploadFile($tmpFile, $path);
                unlink($tmpFile);
index 6c57405619af0b0bf87a558015c89ea072e99d43..a62b7d727fb0a26404a99f44e4eedd758f904be5 100644 (file)
@@ -876,7 +876,10 @@ abstract class Common implements Storage, ILockingStorage, IWriteStreamStorage {
                        while (($file = readdir($dh)) !== false) {
                                if (!Filesystem::isIgnoredDir($file) && !Filesystem::isFileBlacklisted($file)) {
                                        $childPath = $basePath . '/' . trim($file, '/');
-                                       yield $this->getMetaData($childPath);
+                                       $metadata = $this->getMetaData($childPath);
+                                       if ($metadata !== null) {
+                                               yield $metadata;
+                                       }
                                }
                        }
                }