Resolves: RHEL-19371 (Backport upstream patch to workaround broken text/calendar mail attachments by the server)

This commit is contained in:
Milan Crha 2023-12-13 13:32:57 +01:00
parent 8e02222039
commit 3b0934cb1c
2 changed files with 77 additions and 1 deletions

View File

@ -0,0 +1,71 @@
From 19678170eb8a36c67dabf4c7eb234a69f032d94b Mon Sep 17 00:00:00 2001
Date: Wed, 13 Dec 2023 12:16:45 +0100
Subject: [PATCH] I#250 - Mail: Calendar attachments can be broken by the
server
Closes https://gitlab.gnome.org/GNOME/evolution-ews/-/issues/250
---
src/EWS/camel/camel-ews-folder.c | 33 ++++++++++++++++++++++++++++++--
1 file changed, 31 insertions(+), 2 deletions(-)
diff --git a/src/EWS/camel/camel-ews-folder.c b/src/EWS/camel/camel-ews-folder.c
index 84fdcf11..b1203489 100644
--- a/src/EWS/camel/camel-ews-folder.c
+++ b/src/EWS/camel/camel-ews-folder.c
@@ -344,7 +344,7 @@ ews_get_calendar_mime_part (CamelMimePart *mimepart)
}
static gchar *
-ews_update_mgtrequest_mime_calendar_itemid (const gchar *mime_fname,
+ews_update_mtgrequest_mime_calendar_itemid (const gchar *mime_fname,
const EwsId *calendar_item_id,
gboolean is_calendar_UID,
const EwsId *mail_item_id,
@@ -404,6 +404,35 @@ ews_update_mgtrequest_mime_calendar_itemid (const gchar *mime_fname,
if (ba && ba->len) {
g_byte_array_append (ba, (guint8 *) "\0", 1);
icomp = i_cal_parser_parse_string ((gchar *) ba->data);
+ if (!icomp) {
+ const gchar *content = (const gchar *) ba->data;
+ const gchar *begin_vcalendar, *end_vcalendar;
+
+ /* Workaround Office365.com error, which returns invalid iCalendar object (without 'END:VCALENDAR'),
+ in the MimeContent's text/calendar attachments as of 2023-12-12. */
+ begin_vcalendar = camel_strstrcase (content, "BEGIN:VCALENDAR");
+ end_vcalendar = camel_strstrcase (content, "END:VCALENDAR");
+
+ /* If it exists, then it should be alone on a separate line */
+ if (!(begin_vcalendar && (begin_vcalendar == content || begin_vcalendar[-1] == '\n') &&
+ (begin_vcalendar[15 /* strlen ("BEGIN:VCALENDAR") */] == '\r' || begin_vcalendar[15] == '\n')))
+ begin_vcalendar = NULL;
+
+ /* If it exists, then it should be alone on a separate line and not at the very beginning of the mime_content */
+ if (!(end_vcalendar && end_vcalendar > content && end_vcalendar[-1] == '\n' &&
+ (end_vcalendar[13 /* strlen ("END:VCALENDAR") */] == '\r' || end_vcalendar[13] == '\n' || end_vcalendar[13] == '\0')))
+ end_vcalendar = NULL;
+
+ if (begin_vcalendar && !end_vcalendar) {
+ g_byte_array_remove_index (ba, ba->len - 1);
+ #define add_str(_str) g_byte_array_append (ba, (guint8 *) _str, strlen (_str))
+ add_str ("\r\nEND:VCALENDAR\r\n");
+ #undef add_str
+ g_byte_array_append (ba, (guint8 *) "\0", 1);
+
+ icomp = i_cal_parser_parse_string ((const gchar *) ba->data);
+ }
+ }
}
if (icomp) {
ICalComponent *subcomp;
@@ -922,7 +951,7 @@ camel_ews_folder_get_message (CamelFolder *folder,
e_ews_additional_props_free (add_props);
g_slist_free (html_body_ids);
- mime_fname_new = ews_update_mgtrequest_mime_calendar_itemid (mime_content, calendar_item_accept_id, is_calendar_UID, e_ews_item_get_id (items->data), html_body, error);
+ mime_fname_new = ews_update_mtgrequest_mime_calendar_itemid (mime_content, calendar_item_accept_id, is_calendar_UID, e_ews_item_get_id (items->data), html_body, error);
if (mime_fname_new)
mime_content = (const gchar *) mime_fname_new;
--
2.41.0

View File

@ -6,12 +6,14 @@
Name: evolution-ews
Version: 3.40.4
Release: 1%{?dist}
Release: 2%{?dist}
Summary: Evolution extension for Exchange Web Services
License: LGPLv2+
URL: https://wiki.gnome.org/Apps/Evolution
Source: http://download.gnome.org/sources/%{name}/3.40/%{name}-%{version}.tar.xz
Patch01: 0001-I-250-Mail-Calendar-attachments-can-be-broken-by-the.patch
%global eds_evo_version %{version}
Requires: evolution >= %{eds_evo_version}
@ -92,6 +94,9 @@ export CFLAGS="$RPM_OPT_FLAGS -Wno-deprecated-declarations"
%files langpacks -f %{name}.lang
%changelog
* Wed Dec 13 2023 Milan Crha <mcrha@redhat.com> - 3.40.4-2
- Resolves: RHEL-19371 (Backport upstream patch to workaround broken text/calendar mail attachments by the server)
* Fri Aug 13 2021 Milan Crha <mcrha@redhat.com> - 3.40.4-1
- Related: #1992450 (Update to 3.40.4)