Skip to content

Commit

Permalink
fix baserproject#3154 【5.1】WebサイトURLの書式チェックが行われていません【システム基本設定>WebサイトURL】
Browse files Browse the repository at this point in the history
  • Loading branch information
dovanhung committed Feb 26, 2024
1 parent 16e6519 commit c071154
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
5 changes: 5 additions & 0 deletions plugins/baser-core/src/Model/Table/SiteConfigsTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,12 @@ public function validationKeyValue(Validator $validator): Validator
->notEmptyString('email', __d('baser_core', '管理者メールアドレスを入力してください。'));
$validator
->scalar('site_url')
->regex('site_url', '/^(http|https):/', __d('baser_core', 'WebサイトURLはURLの形式を入力してください。'))
->notEmptyString('site_url', __d('baser_core', 'WebサイトURLを入力してください。'));
$validator
->scalar('ssl_url')
->regex('ssl_url', '/^(http|https):/', __d('baser_core', 'WebサイトURLはURLの形式を入力してください。'))
->notEmptyString('ssl_url', __d('baser_core', 'WebサイトURLを入力してください。'));
$validator
->scalar('admin_ssl')
->add('admin_ssl', [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,34 @@ public function testValidationKeyValueRegular()
'formal_name' => 'hoge',
'name' => 'hoge',
'email' => 'hoge@basercms.net',
'site_url' => 'hoge',
'site_url' => 'https://localhost/',
'ssl_url' => 'https://localhost/',
]);
$this->assertEmpty($errors);
}

/**
* test validationKeyValue url
*/
public function testvalidationKeyValueURL()
{
$validator = $this->SiteConfigs->getValidator('keyValue');
$errors = $validator->validate([
'ssl_url' => 'hoge',
'site_url' => 'hoge',
]);
$this->assertEquals('WebサイトURLはURLの形式を入力してください。', current($errors['ssl_url']));
$this->assertEquals('WebサイトURLはURLの形式を入力してください。', current($errors['site_url']));

$validator = $this->SiteConfigs->getValidator('keyValue');
$errors = $validator->validate([
'ssl_url' => '/hoge',
'site_url' => '/hoge',
]);
$this->assertEquals('WebサイトURLはURLの形式を入力してください。', current($errors['ssl_url']));
$this->assertEquals('WebサイトURLはURLの形式を入力してください。', current($errors['site_url']));
}

/**
* コントロールソースを取得する
*
Expand Down

0 comments on commit c071154

Please sign in to comment.