]> mj.ucw.cz Git - checkmail.git/commitdiff
Fixed formatting of sender addresses combined with personal info
authorMartin Mares <mj@ucw.cz>
Wed, 5 Feb 2014 11:50:32 +0000 (12:50 +0100)
committerMartin Mares <mj@ucw.cz>
Wed, 5 Feb 2014 11:51:38 +0000 (12:51 +0100)
add_snipped() was too agressive with automatic removal of spaces.

charset.c
charset.h
cm.c

index 921be697c528af615c7dffadf2c16548b34a55d6..0f766706fcf79ebe4bdd4735e51336acf6b71376 100644 (file)
--- 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);
 }
index 32f628ad97eea12ef17c92dda112ea55f8935c39..e92bff7b714429718c8d7421c0b77a7cb2c55f92 100644 (file)
--- 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 e7b2e63cf34c71777d74894c8839ab70c3177b0d..257ccec763f221ea0f257e365609454c810e8a06 100644 (file)
--- 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);
 }