Merge pull request #25591 from nextcloud/backport/25582/stable21
[stable21] Do not send imip email to invalid recipients
This commit is contained in:
commit
32a49e228b
|
@ -178,6 +178,11 @@ class IMipPlugin extends SabreIMipPlugin {
|
||||||
// Strip off mailto:
|
// Strip off mailto:
|
||||||
$sender = substr($iTipMessage->sender, 7);
|
$sender = substr($iTipMessage->sender, 7);
|
||||||
$recipient = substr($iTipMessage->recipient, 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;
|
$senderName = $iTipMessage->senderName ?: null;
|
||||||
$recipientName = $iTipMessage->recipientName ?: null;
|
$recipientName = $iTipMessage->recipientName ?: null;
|
||||||
|
|
|
@ -140,6 +140,7 @@ class IMipPluginTest extends TestCase {
|
||||||
->method('getAppValue')
|
->method('getAppValue')
|
||||||
->with('dav', 'invitation_link_recipients', 'yes')
|
->with('dav', 'invitation_link_recipients', 'yes')
|
||||||
->willReturn('yes');
|
->willReturn('yes');
|
||||||
|
$this->mailer->method('validateMailAddress')->willReturn(true);
|
||||||
|
|
||||||
$message = $this->_testMessage();
|
$message = $this->_testMessage();
|
||||||
$this->_expectSend();
|
$this->_expectSend();
|
||||||
|
@ -153,6 +154,7 @@ class IMipPluginTest extends TestCase {
|
||||||
->method('getAppValue')
|
->method('getAppValue')
|
||||||
->with('dav', 'invitation_link_recipients', 'yes')
|
->with('dav', 'invitation_link_recipients', 'yes')
|
||||||
->willReturn('yes');
|
->willReturn('yes');
|
||||||
|
$this->mailer->method('validateMailAddress')->willReturn(true);
|
||||||
|
|
||||||
$message = $this->_testMessage();
|
$message = $this->_testMessage();
|
||||||
$this->mailer
|
$this->mailer
|
||||||
|
@ -163,12 +165,21 @@ class IMipPluginTest extends TestCase {
|
||||||
$this->assertEquals('5.0', $message->getScheduleStatus());
|
$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() {
|
public function testDeliveryWithNoCommonName() {
|
||||||
$this->config
|
$this->config
|
||||||
->expects($this->at(1))
|
->expects($this->at(1))
|
||||||
->method('getAppValue')
|
->method('getAppValue')
|
||||||
->with('dav', 'invitation_link_recipients', 'yes')
|
->with('dav', 'invitation_link_recipients', 'yes')
|
||||||
->willReturn('yes');
|
->willReturn('yes');
|
||||||
|
$this->mailer->method('validateMailAddress')->willReturn(true);
|
||||||
|
|
||||||
$message = $this->_testMessage();
|
$message = $this->_testMessage();
|
||||||
$message->senderName = null;
|
$message->senderName = null;
|
||||||
|
@ -193,6 +204,7 @@ class IMipPluginTest extends TestCase {
|
||||||
$this->config
|
$this->config
|
||||||
->method('getAppValue')
|
->method('getAppValue')
|
||||||
->willReturn('yes');
|
->willReturn('yes');
|
||||||
|
$this->mailer->method('validateMailAddress')->willReturn(true);
|
||||||
|
|
||||||
$message = $this->_testMessage($veventParams);
|
$message = $this->_testMessage($veventParams);
|
||||||
|
|
||||||
|
@ -227,6 +239,7 @@ class IMipPluginTest extends TestCase {
|
||||||
*/
|
*/
|
||||||
public function testIncludeResponseButtons(string $config_setting, string $recipient, bool $has_buttons) {
|
public function testIncludeResponseButtons(string $config_setting, string $recipient, bool $has_buttons) {
|
||||||
$message = $this->_testMessage([],$recipient);
|
$message = $this->_testMessage([],$recipient);
|
||||||
|
$this->mailer->method('validateMailAddress')->willReturn(true);
|
||||||
|
|
||||||
$this->_expectSend($recipient, true, $has_buttons);
|
$this->_expectSend($recipient, true, $has_buttons);
|
||||||
$this->config
|
$this->config
|
||||||
|
@ -256,6 +269,7 @@ class IMipPluginTest extends TestCase {
|
||||||
$this->config
|
$this->config
|
||||||
->method('getAppValue')
|
->method('getAppValue')
|
||||||
->willReturn('yes');
|
->willReturn('yes');
|
||||||
|
$this->mailer->method('validateMailAddress')->willReturn(true);
|
||||||
|
|
||||||
$message = $this->_testMessage(['SUMMARY' => '']);
|
$message = $this->_testMessage(['SUMMARY' => '']);
|
||||||
$this->_expectSend('frodo@hobb.it', true, true,'Invitation: Untitled event');
|
$this->_expectSend('frodo@hobb.it', true, true,'Invitation: Untitled event');
|
||||||
|
|
Loading…
Reference in New Issue