From 8edf58f2eb3c724e1b78057bd75349d64b58e8a7 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 86cecf26966ad..31b187b3ade3c 100644 --- a/apps/files_external/lib/Lib/Storage/AmazonS3.php +++ b/apps/files_external/lib/Lib/Storage/AmazonS3.php @@ -646,6 +646,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;