Skip to content

Commit 326b94a

Browse files
committed
fix: Address review comments
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
1 parent 70e7fea commit 326b94a

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

lib/public/TaskProcessing/FileShaped.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22

33
/**
4-
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
4+
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
55
* SPDX-License-Identifier: AGPL-3.0-or-later
66
*/
77

@@ -15,7 +15,7 @@
1515
* @since 35.0.0
1616
*/
1717
#[Consumable(since: '35.0.0')]
18-
class FileShaped {
18+
final class FileShaped {
1919
/**
2020
* @param EShapeType $shapeType
2121
* @param string $data
@@ -26,8 +26,9 @@ class FileShaped {
2626
public function __construct(
2727
private EShapeType $shapeType,
2828
private string $data,
29-
private string $extension = 'bin',
29+
private string $extension = '',
3030
) {
31+
$this->extension = self::sanitizeExtension($this->extension);
3132
}
3233

3334
/**
@@ -60,6 +61,9 @@ public static function sanitizeExtension(string $ext): string {
6061
return '';
6162
}
6263
$ext = str_replace(['.', '/'], '', $ext);
64+
$ext = preg_replace('/[^A-Za-z0-9]/', '', $ext) ?? $ext;
65+
$ext = strtolower($ext);
66+
$ext = substr($ext, 0, 16);
6367
return $ext;
6468
}
6569
}

0 commit comments

Comments
 (0)