diff options
author | Christoph Wurst <christoph@winzerhof-wurst.at> | 2021-02-11 13:27:02 +0100 |
---|---|---|
committer | backportbot[bot] <backportbot[bot]@users.noreply.github.com> | 2021-02-11 19:00:23 +0000 |
commit | 3878bcbc11c51963ca4221ebe865cf6f0d440000 (patch) | |
tree | f5db4d6d46a452b12c7a691920dcee5fcf5a281e /apps/dav | |
parent | 1ddf59efc0256df0ec181fb54b017621b213044a (diff) | |
download | nextcloud-server-3878bcbc11c51963ca4221ebe865cf6f0d440000.tar.gz nextcloud-server-3878bcbc11c51963ca4221ebe865cf6f0d440000.zip |
Do not send imip email to invalid recipients
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'apps/dav')
-rw-r--r-- | apps/dav/lib/CalDAV/Schedule/IMipPlugin.php | 5 | ||||
-rw-r--r-- | apps/dav/tests/unit/CalDAV/Schedule/IMipPluginTest.php | 14 |
2 files changed, 19 insertions, 0 deletions
diff --git a/apps/dav/lib/CalDAV/Schedule/IMipPlugin.php b/apps/dav/lib/CalDAV/Schedule/IMipPlugin.php index b88364aaa9d..bfc82c0ee90 100644 --- a/apps/dav/lib/CalDAV/Schedule/IMipPlugin.php +++ b/apps/dav/lib/CalDAV/Schedule/IMipPlugin.php @@ -178,6 +178,11 @@ class IMipPlugin extends SabreIMipPlugin { // Strip off mailto: $sender = substr($iTipMessage->sender, 7); $recipient = substr($iTipMessage->recipient, 7); + if (!$this->mailer->validateMailAddress($recipient)) { + // Nothing to send if the recipient doesn't have a valid email address + $iTipMessage->scheduleStatus = '5.0; EMail delivery failed'; + return; + } $senderName = $iTipMessage->senderName ?: null; $recipientName = $iTipMessage->recipientName ?: null; diff --git a/apps/dav/tests/unit/CalDAV/Schedule/IMipPluginTest.php b/apps/dav/tests/unit/CalDAV/Schedule/IMipPluginTest.php index a31fdfdc5f7..3b2abd8575e 100644 --- a/apps/dav/tests/unit/CalDAV/Schedule/IMipPluginTest.php +++ b/apps/dav/tests/unit/CalDAV/Schedule/IMipPluginTest.php @@ -140,6 +140,7 @@ class IMipPluginTest extends TestCase { ->method('getAppValue') ->with('dav', 'invitation_link_recipients', 'yes') ->willReturn('yes'); + $this->mailer->method('validateMailAddress')->willReturn(true); $message = $this->_testMessage(); $this->_expectSend(); @@ -153,6 +154,7 @@ class IMipPluginTest extends TestCase { ->method('getAppValue') ->with('dav', 'invitation_link_recipients', 'yes') ->willReturn('yes'); + $this->mailer->method('validateMailAddress')->willReturn(true); $message = $this->_testMessage(); $this->mailer @@ -163,12 +165,21 @@ class IMipPluginTest extends TestCase { $this->assertEquals('5.0', $message->getScheduleStatus()); } + public function testInvalidEmailDelivery() { + $this->mailer->method('validateMailAddress')->willReturn(false); + + $message = $this->_testMessage(); + $this->plugin->schedule($message); + $this->assertEquals('5.0', $message->getScheduleStatus()); + } + public function testDeliveryWithNoCommonName() { $this->config ->expects($this->at(1)) ->method('getAppValue') ->with('dav', 'invitation_link_recipients', 'yes') ->willReturn('yes'); + $this->mailer->method('validateMailAddress')->willReturn(true); $message = $this->_testMessage(); $message->senderName = null; @@ -193,6 +204,7 @@ class IMipPluginTest extends TestCase { $this->config ->method('getAppValue') ->willReturn('yes'); + $this->mailer->method('validateMailAddress')->willReturn(true); $message = $this->_testMessage($veventParams); @@ -227,6 +239,7 @@ class IMipPluginTest extends TestCase { */ public function testIncludeResponseButtons(string $config_setting, string $recipient, bool $has_buttons) { $message = $this->_testMessage([],$recipient); + $this->mailer->method('validateMailAddress')->willReturn(true); $this->_expectSend($recipient, true, $has_buttons); $this->config @@ -256,6 +269,7 @@ class IMipPluginTest extends TestCase { $this->config ->method('getAppValue') ->willReturn('yes'); + $this->mailer->method('validateMailAddress')->willReturn(true); $message = $this->_testMessage(['SUMMARY' => '']); $this->_expectSend('frodo@hobb.it', true, true,'Invitation: Untitled event'); |