From 8d4fa6fa473a9f15cdfd2a8fa49277cb2be8efe7 Mon Sep 17 00:00:00 2001 From: Kent Delante Date: Mon, 13 Apr 2026 12:05:15 +0800 Subject: [PATCH] fix(s3): ignore prefixes with 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 ignores it and its contents for S3 external storage. --- apps/files_external/lib/Lib/Storage/AmazonS3.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/apps/files_external/lib/Lib/Storage/AmazonS3.php b/apps/files_external/lib/Lib/Storage/AmazonS3.php index 801de49960a66..e5e1d8485f32d 100644 --- a/apps/files_external/lib/Lib/Storage/AmazonS3.php +++ b/apps/files_external/lib/Lib/Storage/AmazonS3.php @@ -645,6 +645,12 @@ public function getDirectoryContent(string $directory): \Traversable { // sub folders if (is_array($result['CommonPrefixes'])) { foreach ($result['CommonPrefixes'] as $prefix) { + if (preg_match('/\/{2,}$/', $prefix['Prefix'])) { + $this->logger->warning('Detected a repeating delimiter in prefix \'' . $prefix['Prefix'] + . '\'. This is unsupported and its contents have been ignored.'); + continue; + } + $dir = $this->getDirectoryMetaData($prefix['Prefix']); if ($dir) { yield $dir;