Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Add email validation
Signed-off-by: Anna Larch <[email protected]>
  • Loading branch information
miaulalala committed Nov 9, 2022
commit 51ef88347068e3909c366029ef535be08039a5b4
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,10 @@ private function getAllEMailAddressesFromEvent(VEvent $vevent):array {
$emailAddressesOfDelegates = $delegates->getParts();
foreach($emailAddressesOfDelegates as $addressesOfDelegate) {
if (strcasecmp($addressesOfDelegate, 'mailto:') === 0) {
$emailAddresses[substr($addressesOfDelegate, 7)] = [];
$delegateEmail = substr($addressesOfDelegate, 7);
if ($delegateEmail !== false && $this->mailer->validateMailAddress($delegateEmail)) {
$emailAddresses[$delegateEmail] = [];
}
}
}

Expand Down Expand Up @@ -334,8 +337,12 @@ private function getEMailAddressOfAttendee(VObject\Property $attendee):?string {
if (!$this->hasAttendeeMailURI($attendee)) {
return null;
}
$attendeeEMail = substr($attendee->getValue(), 7);
if ($attendeeEMail === false || !$this->mailer->validateMailAddress($attendeeEMail)) {
return null;
}

return substr($attendee->getValue(), 7);
return $attendeeEMail;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,30 +250,20 @@ public function testSendWithAttendees(): void {
$deL10N->method('l')
->will($this->returnArgument(0));

$this->l10nFactory->expects($this->at(0))
$this->l10nFactory->expects(self::exactly(3))
->method('findLanguage')
->with()
->willReturn('en');

$this->l10nFactory->expects($this->at(1))
$this->l10nFactory->expects(self::exactly(3))
->method('languageExists')
->with('dav', 'de')
->withConsecutive(['dav', 'en'], ['dav', 'de'], ['dav', 'de'])
->willReturn(true);

$this->l10nFactory->expects($this->at(2))
$this->l10nFactory->expects(self::exactly(2))
->method('get')
->with('dav', 'de')
->willReturn($enL10N);

$this->l10nFactory->expects($this->at(3))
->method('languageExists')
->with('dav', 'en')
->willReturn(true);

$this->l10nFactory->expects($this->at(4))
->method('get')
->with('dav', 'en')
->willReturn($deL10N);
->withConsecutive(['dav', 'de'], ['dav', 'de'])
->willReturnOnConsecutiveCalls([$deL10N],[$deL10N]);

$template1 = $this->getTemplateMock();
$message11 = $this->getMessageMock('[email protected]', $template1);
Expand All @@ -284,7 +274,7 @@ public function testSendWithAttendees(): void {
$message22 = $this->getMessageMock('[email protected]', $template2);
$message23 = $this->getMessageMock('[email protected]', $template2);

$this->mailer->expects($this->at(0))
$this->mailer->expects(self::exactly(2))
->method('createEMailTemplate')
->with('dav.calendarReminder')
->willReturn($template1);
Expand Down Expand Up @@ -341,9 +331,14 @@ public function testSendWithAttendees(): void {
->willReturn($message23);
$this->mailer->expects($this->at(13))
->method('send')
->with($message23)
->willReturn([]);

->withConsecutive(
[$message11],
[$message12],
[$message13],
[$message21],
[$message22],
[$message23]
)->willReturn([]);
$this->setupURLGeneratorMock(2);

$vcalendar = $this->getAttendeeVCalendar();
Expand Down