From: David Bremner <david@tethera.net>
To: notmuch@notmuchmail.org
Subject: [RFC PATCH 3/3] WIP: escape envelope from
Date: Fri, 11 Feb 2022 22:55:03 -0400 [thread overview]
Message-ID: <20220212025503.1690413-4-david@tethera.net> (raw)
In-Reply-To: <20220212025503.1690413-1-david@tethera.net>
This needs duplicate code elimination.
---
notmuch-insert.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/notmuch-insert.c b/notmuch-insert.c
index 214d4d03..dfeb6322 100644
--- a/notmuch-insert.c
+++ b/notmuch-insert.c
@@ -249,6 +249,8 @@ 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;
@@ -267,6 +269,23 @@ copy_fd (int fdout, int fdin)
}
p = buf;
+
+ if (first && remain >= 5 && 0 == strncmp (buf, "From ", 5)) {
+ ssize_t written = write (fdout, header, strlen(header));
+ if (written < 0 && errno == EINTR)
+ continue;
+ if (written <= 0) {
+ fprintf (stderr, "Error: writing to temporary file: %s",
+ strerror (errno));
+ return false;
+ }
+
+ p += 5;
+ remain -= 5;
+ empty = false;
+ }
+
+ first=false;
do {
ssize_t written = write (fdout, p, remain);
if (written < 0 && errno == EINTR)
--
2.34.1
next prev parent reply other threads:[~2022-02-12 2:56 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-12 2:55 WIP: filter out envelope headers in notmuch-insert David Bremner
2022-02-12 2:55 ` [RFC PATCH 1/3] test: start new corpus of test messages for indexing code David Bremner
2022-02-12 2:55 ` [RFC PATCH 2/3] test: add known broken test for insert with mbox as input David Bremner
2022-02-12 2:55 ` David Bremner [this message]
2022-02-12 11:34 ` WIP: filter out envelope headers in notmuch-insert David Bremner
2022-02-13 14:06 ` David Bremner
[not found] ` <164481580222.17471.7090984749734305531@noble.neil.brown.name>
2022-02-14 11:16 ` David Bremner
2022-02-14 22:23 ` NeilBrown
2022-02-14 23:52 ` David Bremner
2022-02-15 1:13 ` NeilBrown
2022-02-15 2:15 ` David Bremner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://notmuchmail.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220212025503.1690413-4-david@tethera.net \
--to=david@tethera.net \
--cc=notmuch@notmuchmail.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://yhetil.org/notmuch.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).