[balsa] Encode and Decode UniqueMessageData URIs



commit c143efcc8f963ff9ae74c33c6c9403c13f47a0dc
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date:   Mon Sep 7 17:59:26 2009 -0400

    Encode and Decode UniqueMessageData URIs

 ChangeLog  |    7 +++++++
 src/main.c |   21 +++++++++++++--------
 2 files changed, 20 insertions(+), 8 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index aa60a34..1b568d6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2009-09-07  Peter Bloomfield
 
+	* src/main.c (balsa_handle_automation_options): encode URI for
+	UniqueMessageData.
+	(mw_message_received_cb): decode URI received from
+	UniqueMessageData.
+
+2009-09-07  Peter Bloomfield
+
 	* libbalsa/misc.c (libbalsa_urlencode): handle 8-bit characters.
 
 2009-09-07  Peter Bloomfield
diff --git a/src/main.c b/src/main.c
index 1e54854..cef3448 100644
--- a/src/main.c
+++ b/src/main.c
@@ -229,13 +229,17 @@ mw_message_received_cb(UniqueApp         *app,
 
         uris = unique_message_data_get_uris(message);
         text = uris[0];
-        if (g_ascii_strncasecmp(text, "mailto:";, 7) == 0)
-            sendmsg_window_process_url(text + 7,
-                                       sendmsg_window_set_field, snd);
-        else
-            sendmsg_window_set_field(snd, "to", text);
-        for (p = uris + 1; *p; p++)
-            add_attachment(snd, *p, FALSE, NULL);
+        if (text) {
+            gchar *decoded = libbalsa_urldecode(text);
+            if (g_ascii_strncasecmp(decoded, "mailto:";, 7) == 0)
+                sendmsg_window_process_url(decoded + 7,
+                                           sendmsg_window_set_field, snd);
+            else
+                sendmsg_window_set_field(snd, "to", decoded);
+            g_free(decoded);
+            for (p = uris + 1; *p; p++)
+                add_attachment(snd, *p, FALSE, NULL);
+        }
         g_strfreev(uris);
         snd->quit_on_close = FALSE;
         break;
@@ -322,7 +326,8 @@ balsa_handle_automation_options(UniqueApp * app)
         gint i;
 
         uris[0] =
-            g_strdup(opt_compose_email ? opt_compose_email : "mailto");
+            libbalsa_urlencode(opt_compose_email ?
+                               opt_compose_email : "mailto");
 
         for (l = opt_attach_list, i = 1; l; l = l->next, i++)
             uris[i] = g_strdup(l->data ? l->data : "");



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