diff options
author | Carl Schwan <carl@carlschwan.eu> | 2022-01-11 15:59:57 +0100 |
---|---|---|
committer | Carl Schwan <carl@carlschwan.eu> | 2022-01-11 20:59:44 +0100 |
commit | 7ecb65f725d7243d3f1433bb8d2cd1f981c90c07 (patch) | |
tree | a32be16a82b5f07c529faf82aca2982400917646 /lib/private/Collaboration | |
parent | d4a5e480ab9fb2337909f1be3c30048a8eb14d78 (diff) | |
download | nextcloud-server-7ecb65f725d7243d3f1433bb8d2cd1f981c90c07.tar.gz nextcloud-server-7ecb65f725d7243d3f1433bb8d2cd1f981c90c07.zip |
Add check before sending email that email address is valid
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
Diffstat (limited to 'lib/private/Collaboration')
-rw-r--r-- | lib/private/Collaboration/Collaborators/MailPlugin.php | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/lib/private/Collaboration/Collaborators/MailPlugin.php b/lib/private/Collaboration/Collaborators/MailPlugin.php index 53a223b38dd..aae6f305981 100644 --- a/lib/private/Collaboration/Collaborators/MailPlugin.php +++ b/lib/private/Collaboration/Collaborators/MailPlugin.php @@ -38,6 +38,7 @@ use OCP\IGroupManager; use OCP\IUser; use OCP\IUserSession; use OCP\Share\IShare; +use OCP\Mail\IMailer; class MailPlugin implements ISearchPlugin { /* @var bool */ @@ -64,19 +65,23 @@ class MailPlugin implements ISearchPlugin { private $knownUserService; /** @var IUserSession */ private $userSession; + /** @var IMailer */ + private $mailer; public function __construct(IManager $contactsManager, ICloudIdManager $cloudIdManager, IConfig $config, IGroupManager $groupManager, KnownUserService $knownUserService, - IUserSession $userSession) { + IUserSession $userSession, + IMailer $mailer) { $this->contactsManager = $contactsManager; $this->cloudIdManager = $cloudIdManager; $this->config = $config; $this->groupManager = $groupManager; $this->knownUserService = $knownUserService; $this->userSession = $userSession; + $this->mailer = $mailer; $this->shareeEnumeration = $this->config->getAppValue('core', 'shareapi_allow_share_dialog_user_enumeration', 'yes') === 'yes'; $this->shareWithGroupOnly = $this->config->getAppValue('core', 'shareapi_only_share_with_group_members', 'no') === 'yes'; @@ -247,14 +252,10 @@ class MailPlugin implements ISearchPlugin { $userResults['wide'] = array_slice($userResults['wide'], $offset, $limit); } - [$username, $domain] = explode('@', $search); - $domain = idn_to_ascii($domain); - $searchIdn = $username . '@' . $domain; - - if (!$searchResult->hasExactIdMatch($emailType) && filter_var($searchIdn, FILTER_VALIDATE_EMAIL)) { + if (!$searchResult->hasExactIdMatch($emailType) && $this->mailer->validateMailAddress($search)) { $result['exact'][] = [ 'label' => $search, - 'uuid' => $searchIdn, + 'uuid' => $search, 'value' => [ 'shareType' => IShare::TYPE_EMAIL, 'shareWith' => $search, |