diff options
author | Ferdinand Thiessen <opensource@fthiessen.de> | 2024-02-23 02:25:23 +0100 |
---|---|---|
committer | John Molakvoæ <skjnldsv@users.noreply.github.com> | 2024-02-28 22:19:25 +0100 |
commit | 1017f4f34acd75a7a22b9667b60356c43d773496 (patch) | |
tree | 4c8bf1e1f1f520f265975cd699a6fafe393e7f55 | |
parent | 27642d3e6dc01a387762e0b13fc66557e0c835b2 (diff) | |
download | nextcloud-server-1017f4f34acd75a7a22b9667b60356c43d773496.tar.gz nextcloud-server-1017f4f34acd75a7a22b9667b60356c43d773496.zip |
fix: Also expose forbidden filename character in the capabilities
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
-rw-r--r-- | apps/files/lib/Capabilities.php | 5 | ||||
-rw-r--r-- | apps/files/openapi.json | 7 | ||||
-rw-r--r-- | config/config.sample.php | 2 | ||||
-rw-r--r-- | lib/public/Util.php | 5 |
4 files changed, 15 insertions, 4 deletions
diff --git a/apps/files/lib/Capabilities.php b/apps/files/lib/Capabilities.php index dc2aae6acfc..0fc95d67226 100644 --- a/apps/files/lib/Capabilities.php +++ b/apps/files/lib/Capabilities.php @@ -39,13 +39,14 @@ class Capabilities implements ICapability { /** * Return this classes capabilities * - * @return array{files: array{bigfilechunking: bool, blacklisted_files: array<mixed>}} + * @return array{files: array{bigfilechunking: bool, blacklisted_files: array<mixed>, forbidden_filename_characters: array<string>}} */ public function getCapabilities() { return [ 'files' => [ 'bigfilechunking' => true, - 'blacklisted_files' => (array)$this->config->getSystemValue('blacklisted_files', ['.htaccess']) + 'blacklisted_files' => (array)$this->config->getSystemValue('blacklisted_files', ['.htaccess']), + 'forbidden_filename_characters' => \OCP\Util::getForbiddenFileNameChars(), ], ]; } diff --git a/apps/files/openapi.json b/apps/files/openapi.json index f9432f6c57c..f9cdb67783d 100644 --- a/apps/files/openapi.json +++ b/apps/files/openapi.json @@ -31,6 +31,7 @@ "required": [ "bigfilechunking", "blacklisted_files", + "forbidden_filename_characters", "directEditing" ], "properties": { @@ -43,6 +44,12 @@ "type": "object" } }, + "forbidden_filename_characters": { + "type": "array", + "items": { + "type": "string" + } + }, "directEditing": { "type": "object", "required": [ diff --git a/config/config.sample.php b/config/config.sample.php index d999b1e39b0..79f813a4dae 100644 --- a/config/config.sample.php +++ b/config/config.sample.php @@ -1962,6 +1962,8 @@ $CONFIG = [ /** * Blacklist characters from being used in filenames. This is useful if you * have a filesystem or OS which does not support certain characters like windows. + * + * The '/' and '\' characters are always forbidden. * * Example for windows systems: ``array('?', '<', '>', ':', '*', '|', '"', chr(0), "\n", "\r")`` * see https://en.wikipedia.org/wiki/Comparison_of_file_systems#Limits diff --git a/lib/public/Util.php b/lib/public/Util.php index e70f084b576..e3f394c1ca9 100644 --- a/lib/public/Util.php +++ b/lib/public/Util.php @@ -51,6 +51,7 @@ use OC\AppScriptDependency; use OC\AppScriptSort; use OCP\Share\IManager; use Psr\Container\ContainerExceptionInterface; +use Psr\Log\LoggerInterface; /** * This class provides different helper functions to make the life of a developer easier @@ -533,9 +534,9 @@ class Util { } // Get admin defined invalid characters - $additionalChars = \OC::$server->getConfig()->getSystemValue('forbidden_chars', []); + $additionalChars = \OCP\Server::get(IConfig::class)->getSystemValue('forbidden_chars', []); if (!is_array($additionalChars)) { - \OC::$server->getLogger()->error('Invalid system config value for "forbidden_chars" is ignored.'); + \OCP\Server::get(LoggerInterface::class)->error('Invalid system config value for "forbidden_chars" is ignored.'); $additionalChars = []; } return array_merge($invalidChars, $additionalChars); |