Validate email in occ command

Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
This commit is contained in:
Daniel Kesselberg 2018-09-25 21:53:04 +02:00 committed by Roeland Jago Douma
parent 13877c2d20
commit a4eb3ee508
No known key found for this signature in database
GPG key ID: F941078878347C0C
2 changed files with 5 additions and 6 deletions

View file

@ -171,6 +171,10 @@ class Install extends Command {
$adminPassword = $helper->ask($input, $output, $question);
}
if ($adminEmail !== null && !filter_var($adminEmail, FILTER_VALIDATE_EMAIL)) {
throw new InvalidArgumentException('Invalid e-mail-address <' . $adminEmail . '> for <' . $adminLogin . '>.');
}
$options = [
'dbtype' => $db,
'dbuser' => $dbUser,

View file

@ -416,12 +416,7 @@ class Setup {
// Set email for admin
if (!empty($options['adminemail'])) {
$adminEmail = htmlspecialchars_decode($options['adminemail']);
if (filter_var($adminEmail, FILTER_VALIDATE_EMAIL)) {
$config->setUserValue($user->getUID(), 'settings', 'email', $adminEmail);
} else {
$error[] = "Invalid e-mail-address <$adminEmail> for <$username>.";
}
$config->setUserValue($user->getUID(), 'settings', 'email', $options['adminemail']);
}
}