diff --git a/app/config/eccube/packages/eccube.yaml b/app/config/eccube/packages/eccube.yaml index a4015de8f1f..747994204a4 100644 --- a/app/config/eccube/packages/eccube.yaml +++ b/app/config/eccube/packages/eccube.yaml @@ -151,5 +151,18 @@ parameters: - admin_content_css - admin_content_js - admin_store_template_install + eccube_file_uploadable_extensions: # ファイル管理でアップロード可能な拡張子 + - jpg + - jpeg + - png + - gif + - webp + - ico + - html + - htm + - js + - css + - txt + - pdf eccube_login_throttling_max_attempts: 5 eccube_login_throttling_interval: '30 minutes' diff --git a/src/Eccube/Controller/Admin/Content/FileController.php b/src/Eccube/Controller/Admin/Content/FileController.php index 8ff1c576f1a..6240b569867 100644 --- a/src/Eccube/Controller/Admin/Content/FileController.php +++ b/src/Eccube/Controller/Admin/Content/FileController.php @@ -308,14 +308,14 @@ public function upload(Request $request) if (!preg_match('/\A[a-zA-Z0-9_\-\.\(\) ]+\Z/', $filename)) { throw new UnsupportedMediaTypeHttpException(trans('admin.content.file.folder_name_symbol_error')); } - // phpファイルはアップロード不可 - if ($file->getClientOriginalExtension() === 'php') { - throw new UnsupportedMediaTypeHttpException(trans('admin.content.file.phpfile_error')); - } // dotファイルはアップロード不可 if (strpos($filename, '.') === 0) { throw new UnsupportedMediaTypeHttpException(trans('admin.content.file.dotfile_error')); } + // 許可した拡張子以外アップロード不可 + if (!in_array(strtolower($file->getClientOriginalExtension()), $this->eccubeConfig['eccube_file_uploadable_extensions'], true)) { + throw new UnsupportedMediaTypeHttpException(trans('admin.content.file.extension_error')); + } } catch (UnsupportedMediaTypeHttpException $e) { if (!in_array($e->getMessage(), array_column($this->errors, 'message'))) { $this->errors[] = ['message' => $e->getMessage()]; diff --git a/src/Eccube/Resource/locale/messages.en.yaml b/src/Eccube/Resource/locale/messages.en.yaml index cdbcd642036..5d064bf2a89 100644 --- a/src/Eccube/Resource/locale/messages.en.yaml +++ b/src/Eccube/Resource/locale/messages.en.yaml @@ -990,8 +990,9 @@ admin.content.file.folder_name_symbol_error: The folder name contains invalid ch admin.content.file.folder_name_period_error: Folder names beginning with a period(.) are not allowed. admin.content.file.dir_exists: '%file_name% is already exists.' admin.content.file.same_name_folder_exists: 'Cannot upload because a folder with the same name as the file exists.' -admin.content.file.phpfile_error: 'php files cannot be uploaded.' +admin.content.file.phpfile_error: 'php files cannot be uploaded.' # Unused admin.content.file.dotfile_error: 'Dot files cannot be uploaded.' +admin.content.file.extension_error: 'File extension cannot be uploaded.' admin.content.layout_delete: Delete Layouts admin.content.layout_no_page: Page not registered admin.content.layout__card_title: Layout Overview diff --git a/src/Eccube/Resource/locale/messages.ja.yaml b/src/Eccube/Resource/locale/messages.ja.yaml index 34b0d24bf1a..d315cba64f4 100644 --- a/src/Eccube/Resource/locale/messages.ja.yaml +++ b/src/Eccube/Resource/locale/messages.ja.yaml @@ -990,8 +990,9 @@ admin.content.file.folder_name_symbol_error: 使用できない文字が含ま admin.content.file.folder_name_period_error: ピリオド(.)で始まる名前は使用できません。 admin.content.file.dir_exists: '%file_name% は既に使用されています。別のフォルダ名を入力してください' admin.content.file.same_name_folder_exists: 'ファイルと同じ名前のフォルダが存在するためアップロードできません。' -admin.content.file.phpfile_error: 'phpファイルはアップロードできません。' +admin.content.file.phpfile_error: 'phpファイルはアップロードできません。' # 未使用 admin.content.file.dotfile_error: '.で始まるファイルはアップロードできません。' +admin.content.file.extension_error: 'アップロードできないファイル拡張子です。' admin.content.layout_delete: レイアウトを削除 admin.content.layout_no_page: ページが登録されていません admin.content.layout__card_title: レイアウト概要