Check substr results

Else this might lead to unexpeted errors.
Found by psalm.

Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
This commit is contained in:
Roeland Jago Douma 2021-02-13 15:27:11 +01:00
parent 84de7a8d63
commit 507d5cf8ad
2 changed files with 6 additions and 3 deletions

View File

@ -202,7 +202,7 @@ class EmailProvider extends AbstractProvider {
$organizerEMail = substr($organizer->getValue(), 7); $organizerEMail = substr($organizer->getValue(), 7);
if (!$this->mailer->validateMailAddress($organizerEMail)) { if ($organizerEMail === false || !$this->mailer->validateMailAddress($organizerEMail)) {
return null; return null;
} }

View File

@ -178,7 +178,7 @@ 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)) { if ($recipient === false || !$this->mailer->validateMailAddress($recipient)) {
// Nothing to send if the recipient doesn't have a valid email address // Nothing to send if the recipient doesn't have a valid email address
$iTipMessage->scheduleStatus = '5.0; EMail delivery failed'; $iTipMessage->scheduleStatus = '5.0; EMail delivery failed';
return; return;
@ -239,9 +239,12 @@ class IMipPlugin extends SabreIMipPlugin {
$message = $this->mailer->createMessage() $message = $this->mailer->createMessage()
->setFrom([$fromEMail => $fromName]) ->setFrom([$fromEMail => $fromName])
->setReplyTo([$sender => $senderName])
->setTo([$recipient => $recipientName]); ->setTo([$recipient => $recipientName]);
if ($sender !== false) {
$message->setReplyTo([$sender => $senderName]);
}
$template = $this->mailer->createEMailTemplate('dav.calendarInvite.' . $method, $data); $template = $this->mailer->createEMailTemplate('dav.calendarInvite.' . $method, $data);
$template->addHeader(); $template->addHeader();