summaryrefslogtreecommitdiffstats
path: root/apps/dav/lib
diff options
context:
space:
mode:
authorRichard Steinmetz <richard@steinmetz.cloud>2023-03-01 12:24:28 +0100
committerRichard Steinmetz (Rebase PR Action) <st3iny@users.noreply.github.com>2023-03-02 09:42:10 +0000
commita35b960c7a74c41f24910e3110c7a53a996a70e3 (patch)
tree170bacd7c586a2ca5b770df4f213a34c0daf459a /apps/dav/lib
parent2f64d16afdaeccee608c861a3729c817d7a8e7bb (diff)
downloadnextcloud-server-a35b960c7a74c41f24910e3110c7a53a996a70e3.tar.gz
nextcloud-server-a35b960c7a74c41f24910e3110c7a53a996a70e3.zip
fix(caldav): harden null handling of iMip scheduling method
Signed-off-by: Richard Steinmetz <richard@steinmetz.cloud>
Diffstat (limited to 'apps/dav/lib')
-rw-r--r--apps/dav/lib/CalDAV/Schedule/IMipPlugin.php21
-rw-r--r--apps/dav/lib/CalDAV/Schedule/IMipService.php10
2 files changed, 23 insertions, 8 deletions
diff --git a/apps/dav/lib/CalDAV/Schedule/IMipPlugin.php b/apps/dav/lib/CalDAV/Schedule/IMipPlugin.php
index 646cf0f831a..ca79205c09f 100644
--- a/apps/dav/lib/CalDAV/Schedule/IMipPlugin.php
+++ b/apps/dav/lib/CalDAV/Schedule/IMipPlugin.php
@@ -209,9 +209,11 @@ class IMipPlugin extends SabreIMipPlugin {
$senderName = $senderName->getValue() ?? null;
}
- if ($senderName === null || empty(trim($senderName))) {
+ // Try to get the sender name from the current user id if available.
+ if ($this->userId !== null && ($senderName === null || empty(trim($senderName)))) {
$senderName = $this->userManager->getDisplayName($this->userId);
}
+
$sender = substr($iTipMessage->sender, 7);
switch (strtolower($iTipMessage->method)) {
@@ -229,7 +231,6 @@ class IMipPlugin extends SabreIMipPlugin {
break;
}
-
$data['attendee_name'] = ($recipientName ?: $recipient);
$data['invitee_name'] = ($senderName ?: $sender);
@@ -237,9 +238,19 @@ class IMipPlugin extends SabreIMipPlugin {
$fromName = $this->imipService->getFrom($senderName, $this->defaults->getName());
$message = $this->mailer->createMessage()
- ->setFrom([$fromEMail => $fromName])
- ->setTo([$recipient => $recipientName])
- ->setReplyTo([$sender => $senderName]);
+ ->setFrom([$fromEMail => $fromName]);
+
+ if ($recipientName !== null) {
+ $message->setTo([$recipient => $recipientName]);
+ } else {
+ $message->setTo([$recipient]);
+ }
+
+ if ($senderName !== null) {
+ $message->setReplyTo([$sender => $senderName]);
+ } else {
+ $message->setReplyTo([$sender]);
+ }
$template = $this->mailer->createEMailTemplate('dav.calendarInvite.' . $method, $data);
$template->addHeader();
diff --git a/apps/dav/lib/CalDAV/Schedule/IMipService.php b/apps/dav/lib/CalDAV/Schedule/IMipService.php
index 3e8e72bd2e4..50e770e6b40 100644
--- a/apps/dav/lib/CalDAV/Schedule/IMipService.php
+++ b/apps/dav/lib/CalDAV/Schedule/IMipService.php
@@ -70,11 +70,15 @@ class IMipService {
}
/**
- * @param string $senderName
- * @param $default
+ * @param string|null $senderName
+ * @param string $default
* @return string
*/
- public function getFrom(string $senderName, $default): string {
+ public function getFrom(?string $senderName, string $default): string {
+ if ($senderName === null) {
+ return $default;
+ }
+
return $this->l10n->t('%1$s via %2$s', [$senderName, $default]);
}