From 1bb2bd5d721338af2e344b764975c87b2a63540a Mon Sep 17 00:00:00 2001 From: Jon Trowbridge Date: Wed, 26 Sep 2001 19:44:47 +0000 Subject: Decode our URL before extracting the address to pop up contact info. 2001-09-26 Jon Trowbridge * mail-display.c (html_button_press_event): Decode our URL before extracting the address to pop up contact info. * mail-format.c (write_address): When writing out a mailto: link, make sure we construct a valid URL w/ correct encoding. Make sure our address is properly quoted, if necessary. svn path=/trunk/; revision=13160 --- mail/mail-format.c | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) (limited to 'mail/mail-format.c') diff --git a/mail/mail-format.c b/mail/mail-format.c index f76431bbda..029fb5ab4b 100644 --- a/mail/mail-format.c +++ b/mail/mail-format.c @@ -797,9 +797,8 @@ elide_quotes (const gchar *str) if (c) { while (*c) { - if (*c == '"') - *c = '\''; - ++c; + if (*c != '"') + ++c; } } return cpy; @@ -818,20 +817,27 @@ write_address (MailDisplay *md, const CamelInternetAddress *addr, const char *fi i = 0; while (camel_internet_address_get (addr, i, &name, &email)) { + CamelInternetAddress *subaddr; + gchar *addr_txt, *addr_url; gboolean have_name = name && *name; gboolean have_email = email && *email; gchar *name_arg = NULL; gchar *email_arg = NULL; gchar *name_disp = NULL; gchar *email_disp = NULL; + + subaddr = camel_internet_address_new (); + camel_internet_address_add (subaddr, name, email); + addr_txt = camel_address_encode (CAMEL_ADDRESS (subaddr)); + addr_url = camel_url_encode (addr_txt, TRUE, NULL); + camel_object_unref (CAMEL_OBJECT (subaddr)); if (have_name) { - name_arg = elide_quotes (name); name_disp = e_text_to_html (name, 0); } if (have_email) { - email_arg = elide_quotes (email); + email_arg = elide_quotes (email); /* should never be an issue */ email_disp = e_text_to_html (email, 0); } @@ -844,15 +850,11 @@ write_address (MailDisplay *md, const CamelInternetAddress *addr, const char *fi email_disp = g_strdup ("???"); } - if (have_name) { - mail_html_write (md->html, md->stream, - "%s <\">%s>", - name_disp, name_arg, email_arg, email_disp); - } else { - mail_html_write (md->html, md->stream, - "%s", - email_arg, email_disp); - } + mail_html_write (md->html, md->stream, + "%s <%s>", + have_name ? name_disp : "", + addr_url, + email_disp); } else { char *str; @@ -866,6 +868,8 @@ write_address (MailDisplay *md, const CamelInternetAddress *addr, const char *fi g_free (email_arg); g_free (name_disp); g_free (email_disp); + g_free (addr_txt); + g_free (addr_url); i++; } -- cgit