diff options
author | Daniel Kesselberg <mail@danielkesselberg.de> | 2025-07-03 18:17:48 +0200 |
---|---|---|
committer | Daniel Kesselberg <mail@danielkesselberg.de> | 2025-07-14 15:43:42 +0200 |
commit | 8dafde1fb98db0284272f8b787a58be11c6f9f07 (patch) | |
tree | 95f37b23f8857ffff45e1ba78010f37209574417 | |
parent | 0d8eb3959fb5c5608744c8d186aa548033de65ce (diff) | |
download | nextcloud-server-backport/53814/stable31.tar.gz nextcloud-server-backport/53814/stable31.zip |
fix(imip): set charset for imip attachmentbackport/53814/stable31
Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
-rw-r--r-- | apps/dav/lib/CalDAV/Schedule/IMipPlugin.php | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/apps/dav/lib/CalDAV/Schedule/IMipPlugin.php b/apps/dav/lib/CalDAV/Schedule/IMipPlugin.php index 9df7c1cd492..41190c7100d 100644 --- a/apps/dav/lib/CalDAV/Schedule/IMipPlugin.php +++ b/apps/dav/lib/CalDAV/Schedule/IMipPlugin.php @@ -249,7 +249,6 @@ class IMipPlugin extends SabreIMipPlugin { // convert iTip Message to string $itip_msg = $iTipMessage->message->serialize(); - $user = null; $mailService = null; try { @@ -261,8 +260,14 @@ class IMipPlugin extends SabreIMipPlugin { $mailService = $this->mailManager->findServiceByAddress($user->getUID(), $sender); } } + + // The display name in Nextcloud can use utf-8. + // As the default charset for text/* is us-ascii, it's important to explicitly define it. + // See https://www.rfc-editor.org/rfc/rfc6047.html#section-2.4. + $contentType = 'text/calendar; method=' . $iTipMessage->method . '; charset="utf-8"'; + // evaluate if a mail service was found and has sending capabilities - if ($mailService !== null && $mailService instanceof IMessageSend) { + if ($mailService instanceof IMessageSend) { // construct mail message and set required parameters $message = $mailService->initiateMessage(); $message->setFrom( @@ -274,10 +279,12 @@ class IMipPlugin extends SabreIMipPlugin { $message->setSubject($template->renderSubject()); $message->setBodyPlain($template->renderText()); $message->setBodyHtml($template->renderHtml()); + // Adding name=event.ics is a trick to make the invitation also appear + // as a file attachment in mail clients like Thunderbird or Evolution. $message->setAttachments((new Attachment( $itip_msg, null, - 'text/calendar; name=event.ics; method=' . $iTipMessage->method, + $contentType . '; name=event.ics', true ))); // send message @@ -293,10 +300,12 @@ class IMipPlugin extends SabreIMipPlugin { (($senderName !== null) ? [$sender => $senderName] : [$sender]) ); $message->useTemplate($template); + // Using a different content type because Symfony Mailer/Mime will append the name to + // the content type header and attachInline does not allow null. $message->attachInline( $itip_msg, 'event.ics', - 'text/calendar; method=' . $iTipMessage->method + $contentType, ); $failed = $this->mailer->send($message); } |