Merge pull request #21789 from nextcloud/ftp-filter-hash

filter files containing a hash in the path for ftp storages
This commit is contained in:
Morris Jobke 2020-07-13 10:56:16 +02:00 committed by GitHub
commit 7569bc15bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 1 deletions

View File

@ -35,6 +35,7 @@
namespace OCA\Files_External\Lib\Storage; namespace OCA\Files_External\Lib\Storage;
use Icewind\Streams\CallbackWrapper; use Icewind\Streams\CallbackWrapper;
use Icewind\Streams\IteratorDirectory;
use Icewind\Streams\RetryWrapper; use Icewind\Streams\RetryWrapper;
class FTP extends StreamWrapper { class FTP extends StreamWrapper {
@ -136,6 +137,22 @@ class FTP extends StreamWrapper {
return false; 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) { public function writeBack($tmpFile, $path) {
$this->uploadFile($tmpFile, $path); $this->uploadFile($tmpFile, $path);
unlink($tmpFile); unlink($tmpFile);

View File

@ -876,7 +876,10 @@ abstract class Common implements Storage, ILockingStorage, IWriteStreamStorage {
while (($file = readdir($dh)) !== false) { while (($file = readdir($dh)) !== false) {
if (!Filesystem::isIgnoredDir($file) && !Filesystem::isFileBlacklisted($file)) { if (!Filesystem::isIgnoredDir($file) && !Filesystem::isFileBlacklisted($file)) {
$childPath = $basePath . '/' . trim($file, '/'); $childPath = $basePath . '/' . trim($file, '/');
yield $this->getMetaData($childPath); $metadata = $this->getMetaData($childPath);
if ($metadata !== null) {
yield $metadata;
}
} }
} }
} }