🇯🇵Japan @ytsuhako

Account created on 16 February 2007, almost 18 years ago
#

Recent comments

🇯🇵Japan ytsuhako

Problem solved for me.
Thanks a lot.

🇯🇵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] ?? '';
}

🇯🇵Japan ytsuhako

I can upload if I type docx instead of asterisks in the allowed extensions.

Production build 0.71.5 2024