From 444286d82116038d0b1d511d977144fbae1283ab Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Fri, 24 Mar 2023 09:29:00 +0100 Subject: WebDAV Notes: Fallback to derive component summary from description When the component summary is not received, derive it from the first line of the description, thus the summary is not left empty. Related to https://gitlab.gnome.org/GNOME/evolution-data-server/-/issues/461 --- .../webdav-notes/e-cal-backend-webdav-notes.c | 26 +++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/calendar/backends/webdav-notes/e-cal-backend-webdav-notes.c b/src/calendar/backends/webdav-notes/e-cal-backend-webdav-notes.c index 83e04ed3d..1220e6bac 100644 --- a/src/calendar/backends/webdav-notes/e-cal-backend-webdav-notes.c +++ b/src/calendar/backends/webdav-notes/e-cal-backend-webdav-notes.c @@ -458,9 +458,33 @@ ecb_webdav_notes_new_icomp (glong creation_date, i_cal_component_set_summary (icomp, summary); } - if (description) + if (description && *description) { + const gchar *current_summary; + i_cal_component_set_description (icomp, description); + current_summary = i_cal_component_get_summary (icomp); + + if (!current_summary || !*current_summary) { + const gchar *pos; + + pos = strchr (description, '\n'); + if (pos && pos > description && pos[-1] == '\r') + pos--; + + if (!pos) { + /* single line description */ + i_cal_component_set_summary (icomp, description); + } else if (pos > description) { + gchar *tmp; + + tmp = g_strndup (description, pos - description); + i_cal_component_set_summary (icomp, tmp); + g_free (tmp); + } + } + } + e_cal_util_component_set_x_property (icomp, E_WEBDAV_NOTES_X_ETAG, revision); return icomp; -- cgit v1.2.1