From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id KMl4GMkhB2JwfAEAgWs5BA (envelope-from ) for ; Sat, 12 Feb 2022 03:56:09 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id yFo6EckhB2J/dAAAG6o9tA (envelope-from ) for ; Sat, 12 Feb 2022 03:56:09 +0100 Received: from mail.notmuchmail.org (yantan.tethera.net [IPv6:2a01:4f9:c011:7a79::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id F27CD461EA for ; Sat, 12 Feb 2022 03:56:08 +0100 (CET) Received: from yantan.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id C37975F721; Sat, 12 Feb 2022 02:56:07 +0000 (UTC) Received: from fethera.tethera.net (fethera.tethera.net [IPv6:2607:5300:60:c5::1]) by mail.notmuchmail.org (Postfix) with ESMTP id B39805F700 for ; Sat, 12 Feb 2022 02:56:05 +0000 (UTC) Received: by fethera.tethera.net (Postfix, from userid 1001) id 2F2345FBD2; Fri, 11 Feb 2022 21:56:05 -0500 (EST) Received: (nullmailer pid 1690528 invoked by uid 1000); Sat, 12 Feb 2022 02:55:17 -0000 From: David Bremner To: notmuch@notmuchmail.org Subject: [RFC PATCH 3/3] WIP: escape envelope from Date: Fri, 11 Feb 2022 22:55:03 -0400 Message-Id: <20220212025503.1690413-4-david@tethera.net> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220212025503.1690413-1-david@tethera.net> References: <20220212025503.1690413-1-david@tethera.net> MIME-Version: 1.0 Message-ID-Hash: 6H6UG4AXBEHODHX46FKJXYVBHLSGQJY7 X-Message-ID-Hash: 6H6UG4AXBEHODHX46FKJXYVBHLSGQJY7 X-MailFrom: bremner@tethera.net X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-notmuch.notmuchmail.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.3 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_IN X-Migadu-Country: DE ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1644634569; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-owner:list-unsubscribe:list-subscribe:list-post; bh=4a7T3SjgNYmubUeWD7OiGBtYAjF0BAM+J6LmAt3/HXo=; b=qig3HKcV9lwFG7YgRul2e+Bovq2A8FN+ULl8qdcFyXrmJ5oj+dOzQQLsg2C7QE3jTipG/Y k5u3hr8jmFrjVRJ5qb6Gzq7eUmzwomImdKsxA0xtbzn5BDr2ELsWwgrICuG0pKxcoj/UJ9 W3X2sM19t2nypsvOBT7h7Z5m5WQtRjVXs7b4UU3+JoyRt3wkops49PWgkgeyDBvSN9SNhP PWENL6CdCRNUw60rUj9itB4Xm7myJ07ZJDl3iwuK5SVq1baD7nRmbYKxEHyYJafJ/XLuDc U9XUUhOHgpkMRKVM1q+pmXYUgvikF0RgPDTZS/0iT9r/QyG7tHdb6OBSQ2BlDA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1644634569; a=rsa-sha256; cv=none; b=WGU39jpDx9lc86St7YNhP6pOrs9vTIl52K8wySscS3JgKHWfqfPaNSdUyKV1ujzHSiS8rY tW2OTzk0ygoIGORTLNkAbLqwFGQhmnM541ESCCOPxeFMx/i3qpGkOQKyxT4AZ04vpgnw7L o9G+ZI6aTPXLNMGbZ/kHNol6sg94U34JS6mNeQbZGJlkNDthKtJ8X5bZsC8EzD1FCTYd0n 3fMWVhOQ0kyQWvKwyXEtXbzL8oioz5I+qw/XCoOOACexK/Bnnrpy/PTY9TuiHT27TB+nuN RK4IDw/6LfQ0PciX2Qmcl4/4IpKbaBCPcVuCCYSKm66ch/lsRLjpo/RdpZ3DVQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 2a01:4f9:c011:7a79::1 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Spam-Score: -1.33 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 2a01:4f9:c011:7a79::1 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Queue-Id: F27CD461EA X-Spam-Score: -1.33 X-Migadu-Scanner: scn1.migadu.com X-TUID: NIf3qWGNZJcz 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