60934a5dc6
ok aja@
163 lines
5.0 KiB
Plaintext
163 lines
5.0 KiB
Plaintext
$OpenBSD: patch-addressbook_backends_webdav_e-book-backend-webdav_c,v 1.1 2010/05/12 07:17:55 jasper Exp $
|
|
|
|
Resolve bz #604650, Mishandling of '@' in WebDAV contacts username
|
|
git 1220c1d4937a10f185590d593d320624a5b8e5e7
|
|
git 20c5952556b649dfec58f48892364e488c490b6f
|
|
|
|
--- addressbook/backends/webdav/e-book-backend-webdav.c.orig Tue May 11 23:01:40 2010
|
|
+++ addressbook/backends/webdav/e-book-backend-webdav.c Tue May 11 23:07:18 2010
|
|
@@ -45,9 +45,7 @@
|
|
#include <libedata-book/e-book-backend-cache.h>
|
|
#include "e-book-backend-webdav.h"
|
|
|
|
-#include <libsoup/soup-uri.h>
|
|
-#include <libsoup/soup-session-sync.h>
|
|
-#include <libsoup/soup-auth.h>
|
|
+#include <libsoup/soup.h>
|
|
|
|
#include <libxml/parser.h>
|
|
#include <libxml/xmlreader.h>
|
|
@@ -77,6 +75,31 @@ typedef struct {
|
|
EFlag *running;
|
|
} WebdavBackendSearchClosure;
|
|
|
|
+ static void
|
|
+webdav_debug_setup (SoupSession *session)
|
|
+{
|
|
+ const gchar *debug_str;
|
|
+ SoupLogger *logger;
|
|
+ SoupLoggerLogLevel level;
|
|
+
|
|
+ g_return_if_fail (session != NULL);
|
|
+
|
|
+ debug_str = g_getenv ("WEBDAV_DEBUG");
|
|
+ if (!debug_str || !*debug_str)
|
|
+ return;
|
|
+
|
|
+ if (g_ascii_strcasecmp (debug_str, "all") == 0)
|
|
+ level = SOUP_LOGGER_LOG_BODY;
|
|
+ else if (g_ascii_strcasecmp (debug_str, "headers") == 0)
|
|
+ level = SOUP_LOGGER_LOG_HEADERS;
|
|
+ else
|
|
+ level = SOUP_LOGGER_LOG_MINIMAL;
|
|
+
|
|
+ logger = soup_logger_new (level, 100 * 1024 * 1024);
|
|
+ soup_session_add_feature (session, SOUP_SESSION_FEATURE (logger));
|
|
+ g_object_unref (logger);
|
|
+}
|
|
+
|
|
static void
|
|
closure_destroy(WebdavBackendSearchClosure *closure)
|
|
{
|
|
@@ -987,13 +1010,11 @@ e_book_backend_webdav_load_source(EBookBackend *backen
|
|
{
|
|
EBookBackendWebdav *webdav = E_BOOK_BACKEND_WEBDAV(backend);
|
|
EBookBackendWebdavPrivate *priv = webdav->priv;
|
|
- const gchar *uri;
|
|
- const gchar *offline;
|
|
- const gchar *uri_without_protocol;
|
|
- const gchar *protocol;
|
|
- const gchar *use_ssl;
|
|
- const gchar *suffix;
|
|
+ gchar *uri;
|
|
+ const gchar *offline;
|
|
+ const gchar *use_ssl;
|
|
SoupSession *session;
|
|
+ SoupURI *suri;
|
|
|
|
uri = e_source_get_uri(source);
|
|
if (uri == NULL) {
|
|
@@ -1001,36 +1022,65 @@ e_book_backend_webdav_load_source(EBookBackend *backen
|
|
return GNOME_Evolution_Addressbook_OtherError;
|
|
}
|
|
|
|
+ suri = soup_uri_new (uri);
|
|
+ g_free (uri);
|
|
+
|
|
+ if (!suri) {
|
|
+ g_warning ("invalid uri given for addressbook");
|
|
+ return GNOME_Evolution_Addressbook_OtherError;
|
|
+ }
|
|
+
|
|
offline = e_source_get_property(source, "offline_sync");
|
|
if (offline && g_str_equal(offline, "1"))
|
|
priv->marked_for_offline = TRUE;
|
|
|
|
if (priv->mode == GNOME_Evolution_Addressbook_MODE_LOCAL
|
|
&& !priv->marked_for_offline ) {
|
|
+ soup_uri_free (suri);
|
|
return GNOME_Evolution_Addressbook_OfflineUnavailable;
|
|
}
|
|
|
|
- if (strncmp(uri, "webdav://", 9) != 0) {
|
|
+ if (!suri->scheme || !g_str_equal (suri->scheme, "webdav")) {
|
|
/* the book is not for us */
|
|
+ soup_uri_free (suri);
|
|
return GNOME_Evolution_Addressbook_OtherError;
|
|
}
|
|
|
|
- uri_without_protocol = uri + 9;
|
|
- use_ssl = e_source_get_property(source, "use_ssl");
|
|
- if (use_ssl != NULL && strcmp(use_ssl, "1") == 0) {
|
|
- protocol = "https://";
|
|
+ use_ssl = e_source_get_property (source, "use_ssl");
|
|
+ if (use_ssl != NULL && strcmp (use_ssl, "1") == 0) {
|
|
+ soup_uri_set_scheme (suri, "https");
|
|
} else {
|
|
- protocol = "http://";
|
|
+ soup_uri_set_scheme (suri, "https");
|
|
}
|
|
|
|
/* append slash if missing */
|
|
- suffix = "";
|
|
- if (uri_without_protocol[strlen(uri_without_protocol) - 1] != '/')
|
|
- suffix = "/";
|
|
+ if (!suri->path || !*suri->path || suri->path[strlen (suri->path) - 1] != '/') {
|
|
+ gchar *new_path = g_strconcat (suri->path ? suri->path : "", "/", NULL);
|
|
+ soup_uri_set_path (suri, new_path);
|
|
+ g_free (new_path);
|
|
+ }
|
|
|
|
- priv->uri
|
|
- = g_strdup_printf("%s%s%s", protocol, uri_without_protocol, suffix);
|
|
+ if (suri->host && strchr (suri->host, '@')) {
|
|
+ gchar *at = strchr (suri->host, '@');
|
|
+ gchar *new_user;
|
|
|
|
+ *at = '\0';
|
|
+
|
|
+ new_user = g_strconcat (suri->user ? suri->user : "", "@", suri->host, NULL);
|
|
+
|
|
+ *at = '@';
|
|
+ soup_uri_set_host (suri, at + 1);
|
|
+ soup_uri_set_user (suri, new_user);
|
|
+
|
|
+ g_free (new_user);
|
|
+ }
|
|
+
|
|
+ priv->uri = soup_uri_to_string (suri, FALSE);
|
|
+ if (!priv->uri) {
|
|
+ soup_uri_free (suri);
|
|
+ return GNOME_Evolution_Addressbook_OtherError;
|
|
+ }
|
|
+
|
|
priv->cache = e_book_backend_cache_new(priv->uri);
|
|
|
|
session = soup_session_sync_new();
|
|
@@ -1042,12 +1092,15 @@ e_book_backend_webdav_load_source(EBookBackend *backen
|
|
e_proxy_setup_proxy (priv->proxy);
|
|
g_signal_connect (priv->proxy, "changed", G_CALLBACK (proxy_settings_changed), priv);
|
|
proxy_settings_changed (priv->proxy, priv);
|
|
+ webdav_debug_setup (priv->session);
|
|
|
|
e_book_backend_notify_auth_required(backend);
|
|
e_book_backend_set_is_loaded(backend, TRUE);
|
|
e_book_backend_notify_connection_status(backend, TRUE);
|
|
e_book_backend_set_is_writable(backend, TRUE);
|
|
e_book_backend_notify_writable(backend, TRUE);
|
|
+
|
|
+ soup_uri_free (suri);
|
|
|
|
return GNOME_Evolution_Addressbook_Success;
|
|
}
|