Fixes NB#121112, dbus API does not support filenames with commas
authorSergio Villar Senin <svillar@igalia.com>
Mon, 8 Jun 2009 08:07:29 +0000 (10:07 +0200)
committerSergio Villar Senin <svillar@igalia.com>
Mon, 8 Jun 2009 08:07:29 +0000 (10:07 +0200)
Now attachments URI's are properly escaped before transmitting them through DBus

libmodest-dbus-client/libmodest-dbus-client.c
src/dbus_api/modest-dbus-callbacks.c
tests/dbus_api/test_compose_mail.c

index 35041ac..7363537 100644 (file)
@@ -44,24 +44,26 @@ static gchar* get_attachments_string (GSList *attachments)
 {
        if (!attachments)
                return NULL;
-               
+
        gchar *attachments_str = g_strdup("");
-       
+
        GSList *iter = attachments;
        while (iter)
        {
                if (iter->data) {
-                       gchar *tmp = g_strconcat(attachments_str, ",", (gchar *) (iter->data), NULL);
+                       gchar *escaped;
+                       gchar *tmp;
+                       escaped = g_uri_escape_string ((const gchar *) (iter->data), NULL, TRUE);
+                       tmp = g_strconcat(attachments_str, ",", escaped, NULL);
+                       g_free(escaped);
                        g_free(attachments_str);
                        attachments_str = tmp;
                }
-               
                iter = g_slist_next(iter);
        }
-       
        return attachments_str;
 }
-       
+
 /**
  * libmodest_dbus_client_mail_to:
  * @osso_context: a valid #osso_context_t object.
index bdeb20a..4b6a4ef 100644 (file)
@@ -286,7 +286,7 @@ on_idle_compose_mail(gpointer user_data)
                gchar **list = g_strsplit(idle_data->attachments, ",", 0);
                gint i = 0;
                for (i=0; list[i] != NULL; i++) {
-                       attachments = g_slist_append(attachments, g_strdup(list[i]));
+                       attachments = g_slist_append(attachments, g_uri_unescape_string (list[i], NULL));
                }
                g_strfreev(list);
        }
index 9abd2ae..a855675 100644 (file)
@@ -18,7 +18,9 @@ int main(int argc, char *argv[])
        
        /* Call the function in libmodest-dbus-client: */
        
-       attachments = g_slist_append(attachments, "file:///usr/include/math.h,file:///usr/include/glib-2.0/glib.h");
+       attachments = g_slist_append(attachments, "file:///usr/include/math.h");
+       attachments = g_slist_append(attachments, "file:///usr/include/glib-2.0/glib.h");
+       attachments = g_slist_append(attachments, "file:///tmp/file,coma.txt");
        
        const gboolean ret = libmodest_dbus_client_compose_mail (
                osso_context,