Micro-optimize validation of empty email addresses

Then we don't have to construct any validators.

Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
This commit is contained in:
Christoph Wurst 2021-02-11 15:15:38 +01:00
parent d5dea10517
commit 883848b58a
No known key found for this signature in database
GPG Key ID: CC42AC2A7F0E56D8
2 changed files with 5 additions and 0 deletions

View File

@ -221,6 +221,10 @@ class Mailer implements IMailer {
* @return bool True if the mail address is valid, false otherwise
*/
public function validateMailAddress(string $email): bool {
if ($email === '') {
// Shortcut: empty addresses are never valid
return false;
}
$validator = new EmailValidator();
$validation = new RFCValidation();

View File

@ -178,6 +178,7 @@ class MailerTest extends TestCase {
['lukas@192.168.1.1', true],
['lukas@éxämplè.com', true],
['asdf', false],
['', false],
['lukas@owncloud.org@owncloud.com', false],
];
}