From a2be017cfee7e0f59b381f04d80753af6e916837 Mon Sep 17 00:00:00 2001 From: Kent Delante Date: Mon, 13 Apr 2026 12:05:15 +0800 Subject: [PATCH] fix(s3): handle repeating delimiters Signed-off-by: Kent Delante Amazon's hosted S3 service allows repeating delimiters in keys (e.g. 'path/to//file.txt' or 'path/to///file.txt') and we get repeating directories in the filecache as a result (based on the previous examples we get 'path/to/to/file.txt' or 'path/to/to/to/file.txt'). This handles it for S3 external storage and ignores the repeated pattern. --- apps/files_external/lib/Lib/Storage/AmazonS3.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/apps/files_external/lib/Lib/Storage/AmazonS3.php b/apps/files_external/lib/Lib/Storage/AmazonS3.php index fdcbf33627e17..df0cab575ed5a 100644 --- a/apps/files_external/lib/Lib/Storage/AmazonS3.php +++ b/apps/files_external/lib/Lib/Storage/AmazonS3.php @@ -608,6 +608,10 @@ public function getDirectoryContent(string $directory): \Traversable { // sub folders if (is_array($result['CommonPrefixes'])) { foreach ($result['CommonPrefixes'] as $prefix) { + if (preg_match('/\/{2,}$/', $prefix['Prefix'])) { + continue; + } + $dir = $this->getDirectoryMetaData($prefix['Prefix']); if ($dir) { yield $dir;