Remove every control char after colon
authorRicardo Mones <ricardo@mones.org>
Fri, 24 May 2013 12:38:28 +0000 (14:38 +0200)
committerPaul <paul@claws-mail.org>
Sat, 8 Jun 2013 19:56:05 +0000 (20:56 +0100)
The extraheaderrc format doesn't allow data after the header
colon. Other OSes may insert extra characters other than \n,
so, remove them all.
(cherry picked from commit 6b978617931b7116397c6c625a26dc638154dd28)

src/compose.c

index 77370deeab0aa97db1d4039b4dca89f1910ee23f..7b2e6fa0bce61a3e81598d80cfaabc830e1e8ced 100644 (file)
@@ -6625,9 +6625,9 @@ void compose_add_extra_header_entries(GtkListStore *model)
                        goto extra_headers_done;
                }
                while (fgets(buf, BUFFSIZE, exh) != NULL) {
-                       lastc = strlen(buf) - 1;        /* remove trailing \n */
-                       buf[lastc] = (buf[lastc] == '\n')? '\0': buf[lastc];
-                       --lastc;
+                       lastc = strlen(buf) - 1;        /* remove trailing control chars */
+                       while (lastc >= 0 && buf[lastc] != ':')
+                               buf[lastc--] = '\0';
                        if (lastc > 0 && buf[0] != '#' && buf[lastc] == ':') {
                                buf[lastc] = '\0'; /* remove trailing : for comparison */
                                if (custom_header_is_allowed(buf)) {