- Issue created by @ytsuhako
- π―π΅Japan ytsuhako
I can upload if I type docx instead of asterisks in the allowed extensions.
- πΊπΈUnited States joshuasosa
I'm getting the same error with the asterisk meant to allow all file types. Setting a specific list of file types works at least.
- π―π΅Japan ytsuhako
/opt/drupal/web/modules/contrib/imce/src/Plugin/ImcePlugin/Upload.php
if ($exts !== '*') {
$validators['file_validate_extensions'] = [$exts];
}It worked when changed to the following.
if ($exts !== '*') {
$validators['file_validate_extensions'] = [$exts];
} else {
$validators['file_validate_extensions'] = [Null];
}I made this change because it is handled as follows in the core.
/opt/drupal/web/core/modules/file/src/Upload/FileUploadHandler.php
protected function handleExtensionValidation(array &$validators): string {
// Build a list of allowed extensions.
if (isset($validators['file_validate_extensions'])) {
if (!isset($validators['file_validate_extensions'][0])) {
// If 'file_validate_extensions' is set and the list is empty then the
// caller wants to allow any extension. In this case we have to remove the
// validator or else it will reject all extensions.
unset($validators['file_validate_extensions']);
}
}
else {
// No validator was provided, so add one using the default list.
// Build a default non-munged safe list for
// \Drupal\system\EventSubscriber\SecurityFileUploadEventSubscriber::sanitizeName().
$validators['file_validate_extensions'] = [self::DEFAULT_EXTENSIONS];
}
return $validators['file_validate_extensions'][0] ?? '';
} - last update
11 months ago 55 pass - Status changed to Fixed
11 months ago 6:04pm 3 January 2024 Automatically closed - issue fixed for 2 weeks with no activity.
- πΊπΈUnited States ja09
Not sure if this one is fixed... still have the issue after updating to 3.0.12 and core 10.2.7.
I am able to upload files when I put a wildcard (*) in the "Allowed file extensions field", but I'm still getting the error when I limit to certain extensions.