From aba959f67310fdda8926a994a3cf536f200f59dc Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Thu, 4 Feb 2021 21:09:50 +0900 Subject: [PATCH] Fix incorrect parsing of allowed_extensions in file upload config https://xetown.com/questions/1523089 --- modules/file/file.admin.controller.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/modules/file/file.admin.controller.php b/modules/file/file.admin.controller.php index fcb823e21..2d0c0915a 100644 --- a/modules/file/file.admin.controller.php +++ b/modules/file/file.admin.controller.php @@ -102,7 +102,9 @@ class fileAdminController extends file $config->allowed_extensions = strtr(strtolower(trim($config->allowed_filetypes)), array('*.' => '', ';' => ',')); if ($config->allowed_extensions) { - $config->allowed_extensions = array_map('trim', explode(',', $config->allowed_filetypes)); + $config->allowed_extensions = array_filter(array_map('trim', explode(',', $config->allowed_extensions)), function($str) { + return $str !== '*'; + }); $config->allowed_filetypes = implode(';', array_map(function($ext) { return '*.' . $ext; }, $config->allowed_extensions)); @@ -188,7 +190,9 @@ class fileAdminController extends file $config->allowed_extensions = strtr(strtolower(trim($config->allowed_filetypes)), array('*.' => '', ';' => ',')); if ($config->allowed_extensions) { - $config->allowed_extensions = array_map('trim', explode(',', $config->allowed_filetypes)); + $config->allowed_extensions = array_filter(array_map('trim', explode(',', $config->allowed_extensions)), function($str) { + return $str !== '*'; + }); $config->allowed_filetypes = implode(';', array_map(function($ext) { return '*.' . $ext; }, $config->allowed_extensions));