File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -18,19 +18,23 @@ public function rules(): array
1818 ],
1919 'db_host ' => [
2020 'required_unless:connection,sqlite ' ,
21+ 'not_regex:/[\r\n]/ ' ,
2122 ],
2223 'db_port ' => [
2324 'required_unless:connection,sqlite ' ,
2425 'numeric ' ,
2526 ],
2627 'db_name ' => [
2728 'required_unless:connection,sqlite ' ,
29+ 'not_regex:/[\r\n]/ ' ,
2830 ],
2931 'db_user ' => [
3032 'required_unless:connection,sqlite ' ,
33+ 'not_regex:/[\r\n]/ ' ,
3134 ],
3235 'db_password ' => [
3336 'nullable ' ,
37+ 'not_regex:/[\r\n]/ ' ,
3438 ],
3539 ];
3640 }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Tests \Controller ;
4+
5+ use App \Settings \SystemSettings ;
6+ use Illuminate \Foundation \Testing \RefreshDatabase ;
7+ use Tests \TestCase ;
8+
9+ class SetupDatabaseControllerTest extends TestCase
10+ {
11+ use RefreshDatabase;
12+
13+ public function test_database_setup_rejects_multiline_passwords (): void
14+ {
15+ SystemSettings::fake ([
16+ 'setup_completed ' => false ,
17+ ]);
18+
19+ $ response = $ this ->from ('/setup/database ' )->post ('/setup/database ' , [
20+ 'connection ' => 'mysql ' ,
21+ 'db_host ' => '127.0.0.1 ' ,
22+ 'db_port ' => 3306 ,
23+ 'db_name ' => 'linkace ' ,
24+ 'db_user ' => 'linkace ' ,
25+ 'db_password ' => "secret \nMAIL_MAILER=sendmail " ,
26+ ]);
27+
28+ $ response
29+ ->assertRedirect ('/setup/database ' )
30+ ->assertSessionHasErrors ('db_password ' );
31+ }
32+ }
You can’t perform that action at this time.
0 commit comments