Skip to content

Commit 8d4fa6f

Browse files
leftybournesbackportbot[bot]
authored andcommitted
fix(s3): ignore prefixes with repeating delimiters
Signed-off-by: Kent Delante <kent@delante.me> 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.
1 parent e511ce5 commit 8d4fa6f

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

apps/files_external/lib/Lib/Storage/AmazonS3.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -645,6 +645,12 @@ public function getDirectoryContent(string $directory): \Traversable {
645645
// sub folders
646646
if (is_array($result['CommonPrefixes'])) {
647647
foreach ($result['CommonPrefixes'] as $prefix) {
648+
if (preg_match('/\/{2,}$/', $prefix['Prefix'])) {
649+
$this->logger->warning('Detected a repeating delimiter in prefix \'' . $prefix['Prefix']
650+
. '\'. This is unsupported and its contents have been ignored.');
651+
continue;
652+
}
653+
648654
$dir = $this->getDirectoryMetaData($prefix['Prefix']);
649655
if ($dir) {
650656
yield $dir;

0 commit comments

Comments
 (0)