diff options
author | Ferdinand Thiessen <opensource@fthiessen.de> | 2025-04-22 15:03:19 +0200 |
---|---|---|
committer | Ferdinand Thiessen <opensource@fthiessen.de> | 2025-04-22 15:03:19 +0200 |
commit | 5fe29e2a35dccb823a2d36c5ad05dc2f4735ae35 (patch) | |
tree | 475b9d4718c2060f0ffaebf27970cd2ef06408fe | |
parent | efa2cda370fbf433dfb43235a3b271494dc31483 (diff) | |
download | nextcloud-server-fix/allow-255-filenames.tar.gz nextcloud-server-fix/allow-255-filenames.zip |
fix: allow files with 255 characters in filenamefix/allow-255-filenames
Align with Linux length limit instead of arbitrary 250 characters.
Migration should not be too expensive as only the metadata is updated
but no table data is touched.
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
-rw-r--r-- | build/integration/dav_features/dav-v2.feature | 4 | ||||
-rw-r--r-- | core/Migrations/Version13000Date20170718121200.php | 3 | ||||
-rw-r--r-- | core/Migrations/Version32000Date20250422135900.php | 34 | ||||
-rw-r--r-- | lib/private/Files/FilenameValidator.php | 6 |
4 files changed, 41 insertions, 6 deletions
diff --git a/build/integration/dav_features/dav-v2.feature b/build/integration/dav_features/dav-v2.feature index 9eae9a1b5fd..88b9d7c6460 100644 --- a/build/integration/dav_features/dav-v2.feature +++ b/build/integration/dav_features/dav-v2.feature @@ -114,7 +114,7 @@ Feature: dav-v2 And user "user0" exists And user "user0" has a quota of "10 MB" And As an "user0" - When User "user0" uploads file "data/textfile.txt" to "/long-filename-with-250-characters-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.txt" + When User "user0" uploads file "data/textfile.txt" to "/long-filename-with-255-characters-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.txt" Then the HTTP status code should be "201" Scenario: Uploading a file with a too long filename @@ -123,7 +123,7 @@ Feature: dav-v2 And user "user0" exists And user "user0" has a quota of "10 MB" And As an "user0" - When User "user0" uploads file "data/textfile.txt" to "/long-filename-with-251-characters-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.txt" + When User "user0" uploads file "data/textfile.txt" to "/long-filename-with-256-characters-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.txt" Then the HTTP status code should be "400" Scenario: Create a search query on image diff --git a/core/Migrations/Version13000Date20170718121200.php b/core/Migrations/Version13000Date20170718121200.php index 1adbf2f0ea2..e47dd72f7cd 100644 --- a/core/Migrations/Version13000Date20170718121200.php +++ b/core/Migrations/Version13000Date20170718121200.php @@ -178,7 +178,8 @@ class Version13000Date20170718121200 extends SimpleMigrationStep { ]); $table->addColumn('name', 'string', [ 'notnull' => false, - 'length' => 250, + // changed from 250 to 255 in Nextcloud 32 to align with operating systems (Version32000Date20250422135900) + 'length' => 255, ]); $table->addColumn('mimetype', Types::BIGINT, [ 'notnull' => true, diff --git a/core/Migrations/Version32000Date20250422135900.php b/core/Migrations/Version32000Date20250422135900.php new file mode 100644 index 00000000000..f0c511c8144 --- /dev/null +++ b/core/Migrations/Version32000Date20250422135900.php @@ -0,0 +1,34 @@ +<?php + +/** + * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ +namespace OC\Core\Migrations; + +use Closure; +use OCP\DB\ISchemaWrapper; +use OCP\Migration\Attributes\ModifyColumn; +use OCP\Migration\IOutput; +use OCP\Migration\SimpleMigrationStep; + +/** + * Adjust name length to support 255 characters to align with operating systems. + * + * See also Version13000Date20170718121200 + */ +#[ModifyColumn(table: 'filecache', name: 'name', description: 'adjust length to maximal supported 255 characters')] +class Version32000Date20250422135900 extends SimpleMigrationStep { + public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { + /** @var ISchemaWrapper $schema */ + $schema = $schemaClosure(); + + $table = $schema->getTable('filecache'); + $column = $table->getColumn('name'); + if ($column->getLength() < 255) { + $column->setLength(255); + } + + return $schema; + } +} diff --git a/lib/private/Files/FilenameValidator.php b/lib/private/Files/FilenameValidator.php index b1979789ec8..e07c07a9208 100644 --- a/lib/private/Files/FilenameValidator.php +++ b/lib/private/Files/FilenameValidator.php @@ -180,9 +180,9 @@ class FilenameValidator implements IFilenameValidator { throw new InvalidDirectoryException($this->l10n->t('Dot files are not allowed')); } - // 255 characters is the limit on common file systems (ext/xfs) - // oc_filecache has a 250 char length limit for the filename - if (isset($filename[250])) { + // 255 characters is the limit on common file systems (ext/xfs) and in general on Linux. + // this is also the limit of oc_filecache for the filename + if (isset($filename[255])) { throw new FileNameTooLongException(); } |