summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/private/Contacts/ContactsMenu/Providers/EMailProvider.php4
-rw-r--r--tests/lib/Contacts/ContactsMenu/Providers/EMailproviderTest.php24
2 files changed, 28 insertions, 0 deletions
diff --git a/lib/private/Contacts/ContactsMenu/Providers/EMailProvider.php b/lib/private/Contacts/ContactsMenu/Providers/EMailProvider.php
index d5630e6420d..242fbd06a22 100644
--- a/lib/private/Contacts/ContactsMenu/Providers/EMailProvider.php
+++ b/lib/private/Contacts/ContactsMenu/Providers/EMailProvider.php
@@ -52,6 +52,10 @@ class EMailProvider implements IProvider {
public function process(IEntry $entry) {
$iconUrl = $this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath('core', 'actions/mail.svg'));
foreach ($entry->getEMailAddresses() as $address) {
+ if (empty($address)) {
+ // Skip
+ continue;
+ }
$action = $this->actionFactory->newEMailAction($iconUrl, $address, $address);
$entry->addAction($action);
}
diff --git a/tests/lib/Contacts/ContactsMenu/Providers/EMailproviderTest.php b/tests/lib/Contacts/ContactsMenu/Providers/EMailproviderTest.php
index 2d82fa5d68e..353c8d6f58f 100644
--- a/tests/lib/Contacts/ContactsMenu/Providers/EMailproviderTest.php
+++ b/tests/lib/Contacts/ContactsMenu/Providers/EMailproviderTest.php
@@ -79,4 +79,28 @@ class EMailproviderTest extends TestCase {
$this->provider->process($entry);
}
+ public function testProcessEmptyAddress() {
+ $entry = $this->createMock(IEntry::class);
+ $action = $this->createMock(ILinkAction::class);
+ $iconUrl = 'https://example.com/img/actions/icon.svg';
+ $this->urlGenerator->expects($this->once())
+ ->method('imagePath')
+ ->willReturn('img/actions/icon.svg');
+ $this->urlGenerator->expects($this->once())
+ ->method('getAbsoluteURL')
+ ->with('img/actions/icon.svg')
+ ->willReturn($iconUrl);
+ $entry->expects($this->once())
+ ->method('getEMailAddresses')
+ ->willReturn([
+ '',
+ ]);
+ $this->actionFactory->expects($this->never())
+ ->method('newEMailAction');
+ $entry->expects($this->never())
+ ->method('addAction');
+
+ $this->provider->process($entry);
+ }
+
}