X-Git-Url: https://git.cworth.org/git?p=notmuch;a=blobdiff_plain;f=notmuch-insert.c;h=e44607ad45a8fdf9058f3ddf9fa3fc88acb7614e;hp=37b6f3cddacc8cfe589256177e7b9151b0acf397;hb=c6733a45c8ff698505ff330d2edce92c90cbc946;hpb=329bb4ddf4278edb14e3ff335d7547c0e0396b8e diff --git a/notmuch-insert.c b/notmuch-insert.c index 37b6f3cd..e44607ad 100644 --- a/notmuch-insert.c +++ b/notmuch-insert.c @@ -269,10 +269,13 @@ static bool copy_fd (int fdout, int fdin) { bool empty = true; + bool first = true; + const char *header = "X-Envelope-From: "; while (! interrupted) { ssize_t remain; char buf[4096]; + const char *p = buf; remain = read (fdin, buf, sizeof (buf)); if (remain == 0) @@ -284,7 +287,17 @@ copy_fd (int fdout, int fdin) strerror (errno)); return false; } - if (! write_buf (buf, fdout, remain)) + + if (first && remain >= 5 && 0 == strncmp (buf, "From ", 5)) { + if (! write_buf (header, fdout, strlen (header))) + return false; + p += 5; + remain -= 5; + } + + first = false; + + if (! write_buf (p, fdout, remain)) return false; empty = false; }