X-Git-Url: http://git.maemo.org/git/?p=modest;a=blobdiff_plain;f=src%2Fmodest-text-utils.c;h=d1cc2f66905a68696325a971a43b0c578d394cf5;hp=973b19ea13be3ded37d62dc0709b37bc9b0e494d;hb=36d3ba31314ba9b5e8e5a10270c09c74629b973f;hpb=0553c6bb55e67bd3451b3baeaa1c5d5334f859c5 diff --git a/src/modest-text-utils.c b/src/modest-text-utils.c index 973b19e..d1cc2f6 100644 --- a/src/modest-text-utils.c +++ b/src/modest-text-utils.c @@ -105,6 +105,7 @@ static gchar* modest_text_utils_quote_plain_text (const gchar *text, static gchar* modest_text_utils_quote_html (const gchar *text, const gchar *cite, int limit); +static gchar* get_email_from_address (const gchar *address); /* ******************************************************************* */ @@ -262,15 +263,20 @@ modest_text_utils_remove_address (const gchar *address_list, const gchar *addres { gchar *dup, *token, *ptr, *result; GString *filtered_emails; + gchar *email_address; g_return_val_if_fail (address_list, NULL); if (!address) return g_strdup (address_list); + + email_address = get_email_from_address (address); /* search for substring */ - if (!strstr ((const char *) address_list, (const char *) address)) + if (!strstr ((const char *) address_list, (const char *) email_address)) { + g_free (email_address); return g_strdup (address_list); + } dup = g_strdup (address_list); filtered_emails = g_string_new (NULL); @@ -279,7 +285,7 @@ modest_text_utils_remove_address (const gchar *address_list, const gchar *addres while (token != NULL) { /* Add to list if not found */ - if (!strstr ((const char *) token, (const char *) address)) { + if (!strstr ((const char *) token, (const char *) email_address)) { if (filtered_emails->len == 0) g_string_append_printf (filtered_emails, "%s", g_strstrip (token)); else @@ -290,6 +296,7 @@ modest_text_utils_remove_address (const gchar *address_list, const gchar *addres result = filtered_emails->str; /* Clean */ + g_free (email_address); g_free (dup); g_string_free (filtered_emails, FALSE); @@ -1129,3 +1136,17 @@ modest_text_utils_get_display_size (guint64 size) else return g_strdup_printf (_FM("sfil_li_size_1gb_or_greater"), (float) size / GB); } + +static gchar * +get_email_from_address (const gchar * address) +{ + gchar *left_limit, *right_limit; + + left_limit = strstr (address, "<"); + right_limit = g_strrstr (address, ">"); + + if ((left_limit == NULL)||(right_limit == NULL)|| (left_limit > right_limit)) + return g_strdup (address); + else + return g_strndup (left_limit + 1, (right_limit - left_limit) - 1); +}