From 16869234056e4353aade34591cd393844d3c3e5a Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Wed, 5 Feb 2014 12:50:32 +0100 Subject: [PATCH] Fixed formatting of sender addresses combined with personal info add_snipped() was too agressive with automatic removal of spaces. --- charset.c | 18 ++++++++++++++---- charset.h | 1 + cm.c | 4 ++-- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/charset.c b/charset.c index 921be69..0f76670 100644 --- a/charset.c +++ b/charset.c @@ -429,6 +429,16 @@ add_snippet(char **ppos, char *term, char *add) *pos = 0; } +void +add_snippet_raw(char **ppos, char *term, char *add) +{ + char *pos = *ppos; + while (pos < term && *add) + *pos++ = *add++; + *ppos = pos; + *pos = 0; +} + void add_subject_snippet(char **ppos, char *term, char *add) { @@ -448,8 +458,8 @@ add_addr_snippet(char **ppos, char *term, char *add, int add_mbox, int add_perso add_subject_snippet(ppos, term, add); return; } - // debug("%s: pers=%s mbox=%s\n", add, addr->personal, addr->mailbox); rfc2047_decode(&addr->personal); + // debug("%s: pers=%s mbox=%s\n", add, addr->personal, addr->mailbox); if (!addr->mailbox || !addr->mailbox[0]) add_mbox = 0; if (!addr->personal || !addr->personal[0]) @@ -468,13 +478,13 @@ add_addr_snippet(char **ppos, char *term, char *add, int add_mbox, int add_perso if (add_personal) add_snippet(ppos, term, addr->personal); if (add_mbox && add_personal) - add_snippet(ppos, term, " <"); + add_snippet_raw(ppos, term, " <"); if (add_mbox) add_snippet(ppos, term, addr->mailbox); if (add_mbox && add_personal) - add_snippet(ppos, term, ">"); + add_snippet_raw(ppos, term, ">"); } else - add_snippet(ppos, term, "???"); + add_snippet_raw(ppos, term, "???"); rfc822_free_address(&addr); } diff --git a/charset.h b/charset.h index 32f628a..e92bff7 100644 --- a/charset.h +++ b/charset.h @@ -3,4 +3,5 @@ void add_subject_snippet(char **ppos, char *term, char *add); void add_addr_snippet(char **ppos, char *term, char *add, int add_mbox, int add_personal); void add_snippet(char **ppos, char *term, char *add); +void add_snippet_raw(char **ppos, char *term, char *add); void charset_init(void); diff --git a/cm.c b/cm.c index e7b2e63..257ccec 100644 --- a/cm.c +++ b/cm.c @@ -274,7 +274,7 @@ prepare_snippets(struct mbox *b, char *sender, char *subject) if (subject[0]) add_subject_snippet(&pos, term, subject); else - add_snippet(&pos, term, "No subject"); + add_snippet_raw(&pos, term, "No subject"); } static void @@ -283,7 +283,7 @@ build_snippet(char *buf, char *term, struct mbox *b) if (b->sender_snippet[0]) { add_snippet(&buf, term, b->sender_snippet); - add_snippet(&buf, term, ": "); + add_snippet_raw(&buf, term, ": "); } add_snippet(&buf, term, b->subject_snippet); } -- 2.39.5