Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Micro-optimize validation of empty email addresses
Then we don't have to construct any validators.

Signed-off-by: Christoph Wurst <[email protected]>
  • Loading branch information
ChristophWurst committed Feb 11, 2021
commit 883848b58a50b03702eab58f67ca577037fcedab
4 changes: 4 additions & 0 deletions lib/private/Mail/Mailer.php
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,10 @@ public function send(IMessage $message): array {
* @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();

Expand Down
1 change: 1 addition & 0 deletions tests/lib/Mail/MailerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ public function mailAddressProvider() {
['[email protected]', true],
['lukas@éxämplè.com', true],
['asdf', false],
['', false],
['[email protected]@owncloud.com', false],
];
}
Expand Down