Merge pull request #25585 from nextcloud/enhancement/empty-email-validation

Micro-optimize validation of empty email addresses
This commit is contained in:
Roeland Jago Douma 2021-02-11 19:51:06 +01:00 committed by GitHub
commit 37199c1da0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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],
];
}