aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2011-05-09 10:01:19 +0800
committerMatthew Barnes <mbarnes@redhat.com>2011-05-09 10:06:27 +0800
commiteeb642c416a847a81c1aa85548bdcabc0c30b716 (patch)
tree13a62c131594a2eb5416935c19ec5dbbe8b9a708
parent08f13f454699d221aee4bc34dc3fce9e2f46dd40 (diff)
downloadgsoc2013-evolution-eeb642c416a847a81c1aa85548bdcabc0c30b716.tar.gz
gsoc2013-evolution-eeb642c416a847a81c1aa85548bdcabc0c30b716.tar.zst
gsoc2013-evolution-eeb642c416a847a81c1aa85548bdcabc0c30b716.zip
Encode the path part of folder URIs.
Wasn't sure if this was necessary, but it -is- in order to handle the local Junk and Trash vfolder names correctly: .#evolution/Junk .#evolution/Trash If we don't escape the path and we feed camel_url_new() something like "folder://local/.#evolution/Trash", it's gonna think the path is '.' and the rest of it's a fragment.
-rw-r--r--mail/e-mail-folder-utils.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/mail/e-mail-folder-utils.c b/mail/e-mail-folder-utils.c
index fbd2dd3055..d73f13ad5c 100644
--- a/mail/e-mail-folder-utils.c
+++ b/mail/e-mail-folder-utils.c
@@ -176,6 +176,7 @@ e_mail_folder_uri_build (CamelStore *store,
const gchar *folder_name)
{
const gchar *uid;
+ gchar *encoded_name;
gchar *encoded_uid;
gchar *uri;
@@ -187,11 +188,14 @@ e_mail_folder_uri_build (CamelStore *store,
folder_name++;
uid = camel_service_get_uid (CAMEL_SERVICE (store));
+
encoded_uid = camel_url_encode (uid, ":;@/");
+ encoded_name = camel_url_encode (folder_name, "#");
- uri = g_strdup_printf ("folder://%s/%s", encoded_uid, folder_name);
+ uri = g_strdup_printf ("folder://%s/%s", encoded_uid, encoded_name);
g_free (encoded_uid);
+ g_free (encoded_name);
return uri;
}
@@ -230,7 +234,7 @@ e_mail_folder_uri_parse (CamelSession *session,
{
CamelURL *url;
CamelService *service = NULL;
- const gchar *folder_name = NULL;
+ gchar *folder_name = NULL;
gboolean success = FALSE;
g_return_val_if_fail (CAMEL_IS_SESSION (session), FALSE);
@@ -251,7 +255,7 @@ e_mail_folder_uri_parse (CamelSession *session,
}
if (url->path != NULL && *url->path == '/')
- folder_name = url->path + 1;
+ folder_name = camel_url_decode_path (url->path + 1);
/* This style was used to reference accounts by UID before
* CamelServices themselves had UIDs. Some examples are:
@@ -295,7 +299,7 @@ e_mail_folder_uri_parse (CamelSession *session,
}
if (url->path != NULL && *url->path == '/')
- folder_name = url->path + 1;
+ folder_name = g_strdup (url->path + 1);
/* CamelFolderInfo URIs used to embed the store's URI, so the
* folder name is appended as either a path part or a fragment
@@ -312,9 +316,9 @@ e_mail_folder_uri_parse (CamelSession *session,
provider = camel_service_get_provider (service);
if (provider->url_flags & CAMEL_URL_FRAGMENT_IS_PATH)
- folder_name = url->fragment;
+ folder_name = g_strdup (url->fragment);
else if (url->path != NULL && *url->path == '/')
- folder_name = url->path + 1;
+ folder_name = g_strdup (url->path + 1);
}
}
@@ -322,8 +326,10 @@ e_mail_folder_uri_parse (CamelSession *session,
if (out_store != NULL)
*out_store = g_object_ref (service);
- if (out_folder_name != NULL)
- *out_folder_name = g_strdup (folder_name);
+ if (out_folder_name != NULL) {
+ *out_folder_name = folder_name;
+ folder_name = NULL;
+ }
success = TRUE;
} else {
@@ -334,6 +340,8 @@ e_mail_folder_uri_parse (CamelSession *session,
folder_uri);
}
+ g_free (folder_name);
+
camel_url_free (url);
return success;