aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private
diff options
context:
space:
mode:
authorJulius Härtl <jus@bitgrid.net>2022-11-04 18:24:55 +0100
committerGitHub <noreply@github.com>2022-11-04 18:24:55 +0100
commit5c4a66f0c19f5260c0104de31d526c211b801828 (patch)
tree3ddb8975f5b69f2de9dd3c0629528a4bf432413c /lib/private
parentaa3be1111f94ef7979c1a3f1f6a539daf6f3bec4 (diff)
parentfd036f774f92c3f3f8abacd11e8b6d9fc3e75ee5 (diff)
downloadnextcloud-server-5c4a66f0c19f5260c0104de31d526c211b801828.tar.gz
nextcloud-server-5c4a66f0c19f5260c0104de31d526c211b801828.zip
Merge pull request #34775 from nextcloud/bugfix/noid/mailer-set-to
Do not throw errors when invalid setTo email is provided
Diffstat (limited to 'lib/private')
-rw-r--r--lib/private/Mail/Message.php18
1 files changed, 11 insertions, 7 deletions
diff --git a/lib/private/Mail/Message.php b/lib/private/Mail/Message.php
index c1b08b4e231..8b94f44ddba 100644
--- a/lib/private/Mail/Message.php
+++ b/lib/private/Mail/Message.php
@@ -78,14 +78,18 @@ class Message implements IMessage {
$convertedAddresses = [];
foreach ($addresses as $email => $readableName) {
- if (!is_numeric($email)) {
- [$name, $domain] = explode('@', $email, 2);
- $domain = idn_to_ascii($domain, 0, INTL_IDNA_VARIANT_UTS46);
- $convertedAddresses[$name.'@'.$domain] = $readableName;
+ $parsableEmail = is_numeric($email) ? $readableName : $email;
+ if (strpos($parsableEmail, '@') === false) {
+ $convertedAddresses[$parsableEmail] = $readableName;
+ continue;
+ }
+
+ [$name, $domain] = explode('@', $parsableEmail, 2);
+ $domain = idn_to_ascii($domain, 0, INTL_IDNA_VARIANT_UTS46);
+ if (is_numeric($email)) {
+ $convertedAddresses[] = $name . '@' . $domain;
} else {
- [$name, $domain] = explode('@', $readableName, 2);
- $domain = idn_to_ascii($domain, 0, INTL_IDNA_VARIANT_UTS46);
- $convertedAddresses[$email] = $name.'@'.$domain;
+ $convertedAddresses[$name . '@' . $domain] = $readableName;
}
}