[evolution-data-server] [CalDAV/CardDAV] Append ending slash to URL when missing



commit 08aaaf318bd6abbc119aa11c267cd72b3d7a02f3
Author: Milan Crha <mcrha redhat com>
Date:   Thu Oct 26 11:17:54 2017 +0200

    [CalDAV/CardDAV] Append ending slash to URL when missing
    
    The URL set in the ESource is supposed to point to a collection
    and as such should end with a forward slash. While some servers
    do not care that much, some others can report an error when
    the ending slash is missing. This ensures it's always there.
    
    Reported downstream at:
    https://bugzilla.redhat.com/show_bug.cgi?id=1505337

 src/libedataserver/e-webdav-session.c |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)
---
diff --git a/src/libedataserver/e-webdav-session.c b/src/libedataserver/e-webdav-session.c
index c396814..06f3b0d 100644
--- a/src/libedataserver/e-webdav-session.c
+++ b/src/libedataserver/e-webdav-session.c
@@ -654,6 +654,7 @@ e_webdav_session_new_request (EWebDAVSession *webdav,
        SoupURI *soup_uri;
        ESource *source;
        ESourceWebdav *webdav_extension;
+       const gchar *path;
 
        g_return_val_if_fail (E_IS_WEBDAV_SESSION (webdav), NULL);
 
@@ -675,6 +676,17 @@ e_webdav_session_new_request (EWebDAVSession *webdav,
 
        g_return_val_if_fail (soup_uri != NULL, NULL);
 
+       /* The URI in the ESource should be to a collection, with an ending
+          forward slash, thus ensure it's there. */
+       path = soup_uri_get_path (soup_uri);
+       if (!path || !*path || !g_str_has_suffix (path, "/")) {
+               gchar *new_path;
+
+               new_path = g_strconcat (path ? path : "", "/", NULL);
+               soup_uri_set_path (soup_uri, new_path);
+               g_free (new_path);
+       }
+
        request = e_soup_session_new_request_uri (session, method, soup_uri, error);
 
        soup_uri_free (soup_uri);


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