aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Kesselberg <mail@danielkesselberg.de>2025-07-03 18:17:48 +0200
committerDaniel Kesselberg <mail@danielkesselberg.de>2025-07-20 23:35:03 +0200
commitfba2e0597f51f3fb156e1ea1003161d35ea0bd42 (patch)
tree7b801366ac668d05cee6cbceb6e0a13bc718182b
parent8eaac9086f2eb0dfd6d2607ed0f5e7dd2d127db8 (diff)
downloadnextcloud-server-backport/53814/stable30.tar.gz
nextcloud-server-backport/53814/stable30.zip
fix(imip): set charset for imip attachmentbackport/53814/stable30
Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
-rw-r--r--apps/dav/lib/CalDAV/Schedule/IMipPlugin.php17
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 1c44c41e617..202689db68c 100644
--- a/apps/dav/lib/CalDAV/Schedule/IMipPlugin.php
+++ b/apps/dav/lib/CalDAV/Schedule/IMipPlugin.php
@@ -263,7 +263,6 @@ class IMipPlugin extends SabreIMipPlugin {
// convert iTip Message to string
$itip_msg = $iTipMessage->message->serialize();
- $user = null;
$mailService = null;
try {
@@ -275,8 +274,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(
@@ -288,10 +293,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 \OCP\Mail\Provider\Attachment(
$itip_msg,
null,
- 'text/calendar; name=event.ics; method=' . $iTipMessage->method,
+ $contentType . '; name=event.ics',
true
)));
// send message
@@ -307,10 +314,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);
}