aboutsummaryrefslogtreecommitdiffstats
path: root/apps/dav/lib
diff options
context:
space:
mode:
authorRichard Steinmetz <richard@steinmetz.cloud>2023-03-02 12:28:17 +0100
committerGitHub <noreply@github.com>2023-03-02 12:28:17 +0100
commit7a020b1d1a24366a23e506ed55e6dc5a288a776e (patch)
tree0e92a54f85ffb6a5f5208e1241ff843435120b1c /apps/dav/lib
parent289fadfd504f0a36836e8c0a082a51e16d3b8da2 (diff)
parenta35b960c7a74c41f24910e3110c7a53a996a70e3 (diff)
downloadnextcloud-server-7a020b1d1a24366a23e506ed55e6dc5a288a776e.tar.gz
nextcloud-server-7a020b1d1a24366a23e506ed55e6dc5a288a776e.zip
Merge pull request #36935 from nextcloud/fix/noid/imip-plugin-null-hardening
fix(caldav): harden null handling of iMip scheduling method
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]);
}