summaryrefslogtreecommitdiffstats
path: root/apps/dav
diff options
context:
space:
mode:
authorRoeland Jago Douma <rullzer@users.noreply.github.com>2021-02-17 10:38:13 +0100
committerGitHub <noreply@github.com>2021-02-17 10:38:13 +0100
commit8be6692521b0816e3c9de63405b79bcb4b25d0d6 (patch)
treee3d589b2bbc4f1ff43eaa41524898f51faeac6b2 /apps/dav
parentfb2b19221f8bdd16ed1059e0edcf9de7a35d2693 (diff)
parent59805dbe2c99236414ced8f4e234232a46812420 (diff)
downloadnextcloud-server-8be6692521b0816e3c9de63405b79bcb4b25d0d6.tar.gz
nextcloud-server-8be6692521b0816e3c9de63405b79bcb4b25d0d6.zip
Merge pull request #25593 from nextcloud/backport/25582/stable19
[stable19] Do not send imip email to invalid recipients
Diffstat (limited to 'apps/dav')
-rw-r--r--apps/dav/lib/CalDAV/Schedule/IMipPlugin.php5
-rw-r--r--apps/dav/tests/unit/CalDAV/Schedule/IMipPluginTest.php14
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 6358a3a0293..760ab33ebb9 100644
--- a/apps/dav/lib/CalDAV/Schedule/IMipPlugin.php
+++ b/apps/dav/lib/CalDAV/Schedule/IMipPlugin.php
@@ -177,6 +177,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 8faa54f534a..fc9365c01dd 100644
--- a/apps/dav/tests/unit/CalDAV/Schedule/IMipPluginTest.php
+++ b/apps/dav/tests/unit/CalDAV/Schedule/IMipPluginTest.php
@@ -139,6 +139,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();
@@ -151,6 +152,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
@@ -161,11 +163,20 @@ 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
->method('getAppValue')
->with('dav', 'invitation_link_recipients', 'yes')
->willReturn('yes');
+ $this->mailer->method('validateMailAddress')->willReturn(true);
$message = $this->_testMessage();
$message->senderName = null;
@@ -191,6 +202,7 @@ class IMipPluginTest extends TestCase {
->method('getAppValue')
->with('dav', 'invitation_link_recipients', 'yes')
->willReturn('yes');
+ $this->mailer->method('validateMailAddress')->willReturn(true);
$message = $this->_testMessage($veventParams);
@@ -225,6 +237,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
@@ -254,6 +267,7 @@ class IMipPluginTest extends TestCase {
->method('getAppValue')
->with('dav', 'invitation_link_recipients', 'yes')
->willReturn('yes');
+ $this->mailer->method('validateMailAddress')->willReturn(true);
$message = $this->_testMessage(['SUMMARY' => '']);
$this->_expectSend('frodo@hobb.it', true, true,'Invitation: Untitled event');