mirror of
https://github.com/nextcloud/server.git
synced 2025-05-02 13:00:42 +00:00

This allows to configure forbidden filenames (the full filename like `.htaccess`) and also forbidden basenames like `com0` where `com0`, `com0.txt` and `com0.tar.gz` will match. We need this as only using basenames was too restrictive and will cause problems on some systems when updating. Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
39 lines
1.4 KiB
PHP
39 lines
1.4 KiB
PHP
<?php
|
|
|
|
/**
|
|
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
|
|
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
*/
|
|
namespace OCA\Files;
|
|
|
|
use OC\Files\FilenameValidator;
|
|
use OCP\Capabilities\ICapability;
|
|
|
|
class Capabilities implements ICapability {
|
|
|
|
public function __construct(
|
|
protected FilenameValidator $filenameValidator,
|
|
) {
|
|
}
|
|
|
|
/**
|
|
* Return this classes capabilities
|
|
*
|
|
* @return array{files: array{'$comment': ?string, bigfilechunking: bool, blacklisted_files: array<mixed>, forbidden_filenames: list<string>, forbidden_filename_basenames: list<string>, forbidden_filename_characters: list<string>, forbidden_filename_extensions: list<string>}}
|
|
*/
|
|
public function getCapabilities(): array {
|
|
return [
|
|
'files' => [
|
|
'$comment' => '"blacklisted_files" is deprecated as of Nextcloud 30, use "forbidden_filenames" instead',
|
|
'blacklisted_files' => $this->filenameValidator->getForbiddenFilenames(),
|
|
'forbidden_filenames' => $this->filenameValidator->getForbiddenFilenames(),
|
|
'forbidden_filename_basenames' => $this->filenameValidator->getForbiddenBasenames(),
|
|
'forbidden_filename_characters' => $this->filenameValidator->getForbiddenCharacters(),
|
|
'forbidden_filename_extensions' => $this->filenameValidator->getForbiddenExtensions(),
|
|
|
|
'bigfilechunking' => true,
|
|
],
|
|
];
|
|
}
|
|
}
|