From cdfe99bbfd766d293c54ffa93d52c003a074cac0 Mon Sep 17 00:00:00 2001 From: gakigaki Date: Tue, 10 Jun 2025 16:36:19 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=E3=83=87=E3=82=A3=E3=83=AC=E3=82=AF?= =?UTF-8?q?=E3=83=88=E3=83=AA=E5=90=8D=E3=81=AE=E3=83=90=E3=83=AA=E3=83=87?= =?UTF-8?q?=E3=83=BC=E3=82=B7=E3=83=A7=E3=83=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit サーバー側の文字コード設定などでディレクトリ名が文字化けするのを回避 - 使える文字: 半角の英数字、アンダースコア(_)、ハイフン(-) - 先頭の文字: 半角の英数字、またはアンダースコア(_) - 使えない文字: スペース、スラッシュ(/)、その他の記号 --- app/Plugins/Manage/ThemeManage/ThemeManage.php | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/app/Plugins/Manage/ThemeManage/ThemeManage.php b/app/Plugins/Manage/ThemeManage/ThemeManage.php index 97d8fc8c6..c030e19fe 100644 --- a/app/Plugins/Manage/ThemeManage/ThemeManage.php +++ b/app/Plugins/Manage/ThemeManage/ThemeManage.php @@ -290,13 +290,12 @@ public function create($request, $id) // セッション初期化などのLaravel 処理 $request->flash(); - // copy by resources/lang/ja/validation.php - alpha_dash - $messages['dir_name.regex'] = ':attributeには英数字・ハイフン・アンダースコアのみからなる文字列を指定してください。'; + $messages['dir_name.regex'] = '入力された:attributeは使用できません。半角の英数字、アンダースコア(_)、ハイフン(-)のみを使い、先頭がハイフンにならないように入力してください。'; // 項目のエラーチェック $validator = Validator::make($request->all(), [ /* regex:英数字_- OK */ - 'dir_name' => ['required', 'regex:/\w+|[-]+/'], + 'dir_name' => ['required', 'regex:/^\w[\w-]*$/'], 'theme_name' => ['required'], ], $messages); $validator->setAttributeNames([ @@ -870,11 +869,14 @@ public function generate($request, $id) // セッション初期化などのLaravel 処理 $request->flash(); + $messages['dir_name.regex'] = '入力された:attributeは使用できません。半角の英数字、アンダースコア(_)、ハイフン(-)のみを使い、先頭がハイフンにならないように入力してください。'; + // 項目のエラーチェック $validator = Validator::make($request->all(), [ - 'dir_name' => ['required'], + // regex:英数字_- OK + 'dir_name' => ['required', 'regex:/^\w[\w-]*$/'], 'theme_name' => ['required'], - ]); + ], $messages); $validator->setAttributeNames([ 'dir_name' => 'ディレクトリ名', 'theme_name' => 'テーマ名', @@ -884,13 +886,12 @@ public function generate($request, $id) if ($validator->fails()) { return $this->generateIndex($request, $id, $validator->errors()); } -/* TODO 上書きさせるか否か決める + // ディレクトリの存在チェック - if (File::isDirectory(public_path() . '/themes/Users/' . $request->dir_name)) { + if (File::isDirectory(public_path() . '/themes/Users/' . basename($request->dir_name))) { $validator->errors()->add('dir_name', 'このディレクトリは存在します。'); return $this->generateIndex($request, $id, $validator->errors()); } -*/ // 確認ボタンの場合は入力画面に戻る。 $themes_css = $this->getSelectStyle($request);