diff --git a/docker b/docker index fd856c2e02..1be999a369 160000 --- a/docker +++ b/docker @@ -1 +1 @@ -Subproject commit fd856c2e02bba8a2994d83f5a3b401b982ea9395 +Subproject commit 1be999a369607ce44b33dfe760f56980fc69f93e diff --git a/lib/View/fileupload/UploadHandler.php b/lib/View/fileupload/UploadHandler.php index 1f6349c82c..e7c92ad393 100644 --- a/lib/View/fileupload/UploadHandler.php +++ b/lib/View/fileupload/UploadHandler.php @@ -170,7 +170,7 @@ protected function validate(string $uploaded_file, stdClass $file, string $error } if (is_int($this->options['max_number_of_files']) && ( - count($this->get_file_objects()) >= $this->options['max_number_of_files']) + $this->getRealFilesCount() >= $this->options['max_number_of_files']) ) { $file->error = 'Too many files uploaded. Please remove this file to continue.'; @@ -205,6 +205,38 @@ protected function validate(string $uploaded_file, stdClass $file, string $error return true; } + /** + * Counts the number of real files excluding those with specific patterns in their names. + * + * @return int The number of real files that do not match the predefined exclusion pattern. + */ + private function getRealFilesCount(): int + { + $files = $this->get_file_objects(); + + if (empty($files)) { + return 0; + } + + $count = 0; + + // remove sha1 + foreach ($files as $file) { + + // Exclude files with sha1 in the name. + // Ex. 70a1af62ebce284ccaa4ab0dc8a37afb5b4cd296_da39a3ee5e6b4b0d3255bfef95601890afd80709|en-US + $pattern = '/^[a-f0-9]{40}_[a-f0-9]{40}\|[a-zA-Z]{2,3}(?:-[a-zA-Z]{4})?(?:-(?:[a-zA-Z]{2}|[0-9]{3}))?(?:-[a-zA-Z0-9]+)*$/'; + + if (preg_match($pattern, $file->name, $matches)) { + continue; + } + + $count++; + } + + return $count; + } + protected function up_count_name_callback($matches): string { $index = isset($matches[1]) ? intval($matches[1]) + 1 : 1;