[evolution-data-server] evo-I#559 - CalDAV: Unescape URI path parts during refresh in iCloud



commit 5c74c2b9b6ce577cc35631837d7b54c75b34ed44
Author: Milan Crha <mcrha redhat com>
Date:   Thu Aug 8 10:48:46 2019 +0200

    evo-I#559 - CalDAV: Unescape URI path parts during refresh in iCloud
    
    Closes https://gitlab.gnome.org/GNOME/evolution/issues/559

 .../backends/caldav/e-cal-backend-caldav.c         | 64 +++++++++++++++++++++-
 1 file changed, 62 insertions(+), 2 deletions(-)
---
diff --git a/src/calendar/backends/caldav/e-cal-backend-caldav.c 
b/src/calendar/backends/caldav/e-cal-backend-caldav.c
index 5be19fc1d..6628d60dd 100644
--- a/src/calendar/backends/caldav/e-cal-backend-caldav.c
+++ b/src/calendar/backends/caldav/e-cal-backend-caldav.c
@@ -510,8 +510,68 @@ ecb_caldav_multiget_from_sets_sync (ECalBackendCalDAV *cbdav,
                if (cbdav->priv->is_icloud) {
                        gchar *calendar_data = NULL, *etag = NULL;
 
-                       success = e_webdav_session_get_data_sync (webdav,
-                               nfo->extra, NULL, &etag, &calendar_data, NULL, cancellable, error);
+                       success = FALSE;
+
+                       /* iCloud returns '@' escaped as "%40", but it doesn't accept it in GET,
+                          thus try to unescape it, together with some other characters */
+                       if (nfo->extra && strchr (nfo->extra, '%')) {
+                               SoupURI *suri;
+                               gchar *new_uri = NULL;
+
+                               suri = soup_uri_new (nfo->extra);
+
+                               if (suri) {
+                                       const gchar *path;
+
+                                       path = soup_uri_get_path (suri);
+
+                                       if (path && *path) {
+                                               gchar **parts, *new_path;
+                                               gint jj;
+
+                                               parts = g_strsplit (path, "/", -1);
+
+                                               for (jj = 0; parts && parts[jj]; jj++) {
+                                                       if (parts[jj][0]) {
+                                                               gchar *part;
+
+                                                               part = soup_uri_normalize (parts[jj], "@");
+
+                                                               if (part) {
+                                                                       g_free (parts[jj]);
+                                                                       parts[jj] = part;
+                                                               }
+                                                       }
+                                               }
+
+                                               new_path = g_strjoinv ("/", parts);
+                                               soup_uri_set_path (suri, new_path);
+
+                                               new_uri = soup_uri_to_string (suri, FALSE);
+
+                                               g_strfreev (parts);
+                                               g_free (new_path);
+                                       }
+
+                                       soup_uri_free (suri);
+                               }
+
+                               if (new_uri) {
+                                       success = e_webdav_session_get_data_sync (webdav, new_uri, NULL, 
&etag, &calendar_data, NULL, cancellable, NULL);
+
+                                       if (success) {
+                                               /* Remember the corrected URI */
+                                               g_free (nfo->extra);
+                                               nfo->extra = new_uri;
+                                               new_uri = NULL;
+                                       }
+                               }
+
+                               g_free (new_uri);
+                       }
+
+                       if (!success)
+                               success = e_webdav_session_get_data_sync (webdav, nfo->extra, NULL, &etag, 
&calendar_data, NULL, cancellable, error);
 
                        if (success && calendar_data) {
                                ICalComponent *vcalendar;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]