Skip to content

Commit b8bf537

Browse files
authored
cmd(setup): validate email input, closes pterodactyl#3175 (pterodactyl#3716)
1 parent 0d5ff6a commit b8bf537

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

app/Console/Commands/Environment/AppSettingsCommand.php

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use DateTimeZone;
1313
use Illuminate\Console\Command;
1414
use Illuminate\Contracts\Console\Kernel;
15+
use Illuminate\Validation\Factory as ValidatorFactory;
1516
use Pterodactyl\Traits\Commands\EnvironmentWriterTrait;
1617
use Illuminate\Contracts\Config\Repository as ConfigRepository;
1718

@@ -78,12 +79,13 @@ class AppSettingsCommand extends Command
7879
/**
7980
* AppSettingsCommand constructor.
8081
*/
81-
public function __construct(ConfigRepository $config, Kernel $command)
82+
public function __construct(ConfigRepository $config, Kernel $command, ValidatorFactory $validator)
8283
{
8384
parent::__construct();
8485

85-
$this->command = $command;
8686
$this->config = $config;
87+
$this->command = $command;
88+
$this->validator = $validator;
8789
}
8890

8991
/**
@@ -103,6 +105,18 @@ public function handle()
103105
$this->config->get('pterodactyl.service.author', 'unknown@unknown.com')
104106
);
105107

108+
$validator = $this->validator->make(
109+
['email' => $this->variables['APP_SERVICE_AUTHOR']],
110+
['email' => 'email']
111+
);
112+
113+
if ($validator->fails()) {
114+
foreach ($validator->errors()->all() as $error) {
115+
$this->output->error($error);
116+
}
117+
return 1;
118+
}
119+
106120
$this->output->comment(trans('command/messages.environment.app.app_url_help'));
107121
$this->variables['APP_URL'] = $this->option('url') ?? $this->ask(
108122
trans('command/messages.environment.app.app_url'),

0 commit comments

Comments
 (0)