Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Schwan <carl@carlschwan.eu>2022-01-11 17:59:57 +0300
committerCarl Schwan <carl@carlschwan.eu>2022-01-11 22:59:44 +0300
commit7ecb65f725d7243d3f1433bb8d2cd1f981c90c07 (patch)
treea32be16a82b5f07c529faf82aca2982400917646 /apps/sharebymail
parentd4a5e480ab9fb2337909f1be3c30048a8eb14d78 (diff)
Add check before sending email that email address is valid
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
Diffstat (limited to 'apps/sharebymail')
-rw-r--r--apps/sharebymail/lib/ShareByMailProvider.php10
-rw-r--r--apps/sharebymail/tests/ShareByMailProviderTest.php2
2 files changed, 11 insertions, 1 deletions
diff --git a/apps/sharebymail/lib/ShareByMailProvider.php b/apps/sharebymail/lib/ShareByMailProvider.php
index 62ba9d35f3f..65a7498bcd6 100644
--- a/apps/sharebymail/lib/ShareByMailProvider.php
+++ b/apps/sharebymail/lib/ShareByMailProvider.php
@@ -334,6 +334,16 @@ class ShareByMailProvider implements IShareProvider {
$share->getNote()
);
+ if ($this->mailer->validateMailAddress($share->getSharedWith())) {
+ $this->removeShareFromTable($shareId);
+ $e = new HintException('Failed to send share by mail. Got an invalid email address: ' . $share->getSharedWith(),
+ $this->l->t('Failed to send share by email. Got an invalid email address'));
+ $this->logger->error($e->getMessage(), [
+ 'message' => 'Failed to send share by mail. Got an invalid email address ' . $share->getSharedWith(),
+ 'app' => 'sharebymail',
+ ]);
+ }
+
try {
$link = $this->urlGenerator->linkToRouteAbsolute('files_sharing.sharecontroller.showShare',
['token' => $share->getToken()]);
diff --git a/apps/sharebymail/tests/ShareByMailProviderTest.php b/apps/sharebymail/tests/ShareByMailProviderTest.php
index bbe5516408d..45cab303669 100644
--- a/apps/sharebymail/tests/ShareByMailProviderTest.php
+++ b/apps/sharebymail/tests/ShareByMailProviderTest.php
@@ -217,7 +217,7 @@ class ShareByMailProviderTest extends TestCase {
public function testCreateSendPasswordByMailWithoutEnforcedPasswordProtection() {
$share = $this->getMockBuilder(IShare::class)->getMock();
- $share->expects($this->any())->method('getSharedWith')->willReturn('receiver@example.com');
+ $share->expects($this->any())->method('getSharedWith')->willReturn('receiver@examplelölöl.com');
$share->expects($this->any())->method('getSendPasswordByTalk')->willReturn(false);
$share->expects($this->any())->method('getSharedBy')->willReturn('owner');