From 4a011b9d49d23d3f26a9d054b5c9a5412a61b254 Mon Sep 17 00:00:00 2001 From: Not Zed Date: Mon, 19 Jan 2004 01:15:25 +0000 Subject: properly decode the mailto url rather than treating it as a simple string. 2004-01-19 Not Zed * em-folder-view.c (emfv_on_url_cb): properly decode the mailto url rather than treating it as a simple string. * em-format-html.c (efh_format_address): if we have a name part, add it to the mailto part. As per rfc2368. So it isn't lost for clicking/etc. svn path=/trunk/; revision=24298 --- mail/ChangeLog | 9 +++++++++ mail/em-folder-view.c | 16 +++++++++++++--- mail/em-format-html.c | 15 ++++++++++++--- 3 files changed, 34 insertions(+), 6 deletions(-) (limited to 'mail') diff --git a/mail/ChangeLog b/mail/ChangeLog index 214dfd190c..7fcaa927c6 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,3 +1,12 @@ +2004-01-19 Not Zed + + * em-folder-view.c (emfv_on_url_cb): properly decode the mailto + url rather than treating it as a simple string. + + * em-format-html.c (efh_format_address): if we have a name part, + add it to the mailto part. As per rfc2368. So it isn't lost for + clicking/etc. + 2004-01-16 JP Rosevear * em-format-html-display.c (efhd_bonobo_object): pass in an diff --git a/mail/em-folder-view.c b/mail/em-folder-view.c index fd2801f904..66835a56a8 100644 --- a/mail/em-folder-view.c +++ b/mail/em-folder-view.c @@ -2121,9 +2121,19 @@ emfv_on_url_cb (GObject *emitter, const char *url, EMFolderView *emfv) char *nice_url = NULL; if (url) { - if (strncmp (url, "mailto:", 7) == 0) - nice_url = g_strdup_printf (_("Click to mail %s"), url + 7); - else + if (strncmp (url, "mailto:", 7) == 0) { + CamelInternetAddress *cia = camel_internet_address_new(); + CamelURL *curl; + char *addr; + + curl = camel_url_new(url, NULL); + camel_address_decode((CamelAddress *)cia, curl->path); + addr = camel_address_format((CamelAddress *)cia); + nice_url = g_strdup_printf (_("Click to mail %s"), addr&&addr[0]?addr:(url + 7)); + g_free(addr); + camel_url_free(curl); + camel_object_unref(cia); + } else nice_url = g_strdup_printf (_("Click to open %s"), url); } diff --git a/mail/em-format-html.c b/mail/em-format-html.c index edd7c25730..a0346b00b0 100644 --- a/mail/em-format-html.c +++ b/mail/em-format-html.c @@ -1467,10 +1467,19 @@ efh_format_address (GString *out, struct _camel_header_address *a) switch (a->type) { case CAMEL_HEADER_ADDRESS_NAME: - if (name && *name) + if (name && *name) { + char *real, *mailaddr; + g_string_append_printf (out, "%s <", name); - - mailto = camel_url_encode (a->v.addr, ""); + /* rfc2368 for mailto syntax and url encoding extras */ + real = camel_header_encode_phrase(a->name); + mailaddr = g_strdup_printf("%s <%s>", real, a->v.addr); + g_free(real); + mailto = camel_url_encode(mailaddr, "?=&()"); + g_free(mailaddr); + } else { + mailto = camel_url_encode (a->v.addr, "?=&()"); + } addr = camel_text_to_html (a->v.addr, flags, 0); g_string_append_printf (out, "%s", mailto, addr); g_free (mailto); -- cgit v1.2.3