Skip to content

[テーマ管理] ディレクトリ名のバリデーション不備による文字化けや重複の問題を修正しました #2208

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions app/Plugins/Manage/ThemeManage/ThemeManage.php
Original file line number Diff line number Diff line change
Expand Up @@ -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([
Expand Down Expand Up @@ -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' => 'テーマ名',
Expand All @@ -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);
Expand Down