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-06 20:06:44 +0200
commit209ad4e780eec517da617e9136a565e1797d44dd (patch)
tree7f46e46f801564f39d447c95bf0804041380be39
parentae4bbbf82b61b2dfad018ccc1388040c8a723083 (diff)
downloadnextcloud-server-209ad4e780eec517da617e9136a565e1797d44dd.tar.gz
nextcloud-server-209ad4e780eec517da617e9136a565e1797d44dd.zip
fix(imip): set charset for imip attachment
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 1f063540df6..2af6b162d8d 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);
}