Article View: linux.kernel.git
Article #2047[PATCH v5 0/4] imap-send: fix with reordered message headers
From: "Harald Nordgren via GitGitGadge...
Date: Sun, 01 Nov 2026 08:21
Date: Sun, 01 Nov 2026 08:21
117 lines
15448 bytes
15448 bytes
git imap-send rejected patches sent with git send-email, such as ones
fetched from lore with b4, because it expected Date before Subject.
Changes in v5:
* End the header block at an empty line in a CRLF mbox as well, so headers
in the body or in later messages no longer count. Add a test.
Changes in v4:
* Store the tunnel as an allocated pointer, so it is only finished when it
was started, and drop the local tunnel variable
* Add a test for lowercase from:, date: and subject: headers
* Explain in the commit message why dropping the From git-send-email
special case is fine for mboxes written by other scripts
Changes in v3:
* Split concerns into different commits, commit message explains what they
do.
* Handle tunnel leak in the proper place.
Changes in v2:
* Case insensitive header match according to RFC 822/2822/5322.
Harald Nordgren (4):
imap-send: wait for the tunnel command to finish
imap-send: accept messages with Subject before Date
imap-send: check git send-email copies like other messages
imap-send: match header names case insensitively
imap-send.c | 61 ++++++++++++++++++++-------------------
t/t9001-send-email.sh | 66 +++++++++++++++++++++++++++++++++++++++++++
2 files changed, 98 insertions(+), 29 deletions(-)
base-commit: 50fe5cc63f9cd6e89b87a2c9ccf96a444f4cfdb7
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2456%2FHaraldNordgren%2Ffix%2Fimap-send-header-order-v5
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2456/HaraldNordgren/fix/imap-send-header-order-v5
Pull-Request: https://github.com/git/git/pull/2456
Range-diff vs v4:
1: 8941ae12bb = 1: cb27ac3a27 imap-send: wait for the tunnel command to finish
2: ad3158b336 ! 2: fa90c64a5c imap-send: accept messages with Subject before Date
@@ Commit message
and git send-email writes Subject before Date.
Accept the three headers in any order within the header block of each
- message.
+ message, which ends at the first empty line whether the mbox uses LF or
+ CRLF line endings.
Signed-off-by: Harald Nordgren <haraldnordgren@gmail.com>
@@ imap-send.c: static void wrap_in_html(struct strbuf *msg)
+{
+ bool from = false, date = false, subject = false;
+
-+ while ((line = strchr(line, '\n')) && *++line != '\n') {
++ while ((line = strchr(line, '\n')) &&
++ *++line != '\n' && !starts_with(line, "\r\n")) {
+ if (starts_with(line, "From: "))
+ from = true;
+ else if (starts_with(line, "Date: "))
@@ t/t9001-send-email.sh: test_expect_success $PREREQ '--compose handles to headers
+ test_grep "^Sending 1 message to INBOX folder" err &&
+ test_grep "(1/1) done" err
+'
++
++test_expect_success $PREREQ 'imap-send ignores headers in the body of a CRLF mbox' '
++ test_config imap.tunnel ./fake-imap-server &&
++ q_to_cr >crlf.mbox <<-\EOF &&
++ From mboxrd@z Thu Jan 1 00:00:00 1970Q
++ From: Example <from@example.com>Q
++ Subject: Fwd: originalQ
++ Q
++ ---------- Forwarded message ---------Q
++ From: Someone <someone@example.com>Q
++ Date: Thu, 1 Jan 1970 00:00:00 +0000Q
++ Subject: originalQ
++ EOF
++ test_must_fail git imap-send --folder=INBOX <crlf.mbox 2>err &&
++ test_grep "no messages found to send" err
++'
+
test_done
3: 919e38c31d ! 3: 8646185486 imap-send: check git send-email copies like other messages
@@ imap-send.c: static int count_messages(struct strbuf *all_msgs)
break;
## t/t9001-send-email.sh ##
-@@ t/t9001-send-email.sh: test_expect_success $PREREQ 'imap-send accepts a sent patch from the list archiv
- test_grep "(1/1) done" err
+@@ t/t9001-send-email.sh: test_expect_success $PREREQ 'imap-send ignores headers in the body of a CRLF mbo
+ test_grep "no messages found to send" err
'
+test_expect_success $PREREQ '--imap-sent-folder stores a copy of the sent patch' '
4: 5b4a08bbda ! 4: e7d1d7cd72 imap-send: match header names case insensitively
@@ Commit message
## imap-send.c ##
@@ imap-send.c: static bool has_required_headers(const char *line)
- bool from = false, date = false, subject = false;
- while ((line = strchr(line, '\n')) && *++line != '\n') {
+ while ((line = strchr(line, '\n')) &&
+ *++line != '\n' && !starts_with(line, "\r\n")) {
- if (starts_with(line, "From: "))
+ if (istarts_with(line, "From: "))
from = true;
--
gitgitgadget
Technical Details
Message-ID:
<pull.2456.v5.git.git.1793521297.gitgitgadget@gmail.com>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!git+bounces-74045-linux-kernel-git=dewy.ruReferences:
<pull.2456.git.git.1792437558.gitgitgadget@gmail.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!git+bounces-74045-linux-kernel-git=dewy.ru
From: gitgitgadget@gmail.com ("Harald Nordgren via GitGitGadget")
Newsgroups: linux.kernel.git
Subject: [PATCH v5 0/4] imap-send: fix with reordered message headers
Date: Sun, 01 Nov 2026 08:21:33 +0000
Organization: Usenet Network
Message-ID: <pull.2456.v5.git.git.1793521297.gitgitgadget@gmail.com>
References: <pull.2456.git.git.1792437558.gitgitgadget@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
logging-data="2652117"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:AyJ8eQqiMz+tqpHom+zjC89H2aI= sha256:5MfrTYv9pchY6CoypSJIdt5MLMLNE0H3IOzhU66eoAs=
sha1:RXl7QUQDwZu8fcsFDSvOSylt+V0= sha256:GkMZSSdZ6tYvOPws0Ldsy/6lo+zSkuvL7cfMY5DUGqs=
List-ID: <git.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
by mail.dewy.ru (Postfix) with ESMTP id 955851122F9; Sun, 1 Nov 2026 11:22:22 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -2.047
X-Spam-Status: No, score=-2.047 tagged_above=-9999 required=6.31
tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
DKIM_VALID_AU=-0.1, FORGED_GMAIL_RCVD=1,
FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001,
HEADER_FROM_DIFFERENT_DOMAINS=0.25, MAILING_LIST_MULTI=-1,
RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001,
URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
header.d=gmail.com
X-Received: from mail.dewy.ru ([127.0.0.1])
by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
with ESMTP id 4p4OC2ZKXspX;
Sun, 1 Nov 2026 11:22:19 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=git+bounces-74045-linux-kernel-git=dewy.ru@vger.kernel.org; receiver=<UNKNOWN>
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=gmail.com
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
by mail.dewy.ru (Postfix) with ESMTPS id E73B01122E6; Sun, 1 Nov 2026 11:22:10 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
by sea.lore.kernel.org (Postfix) with ESMTP id 0FD9529BB5; Sun, 1 Nov 2026 08:21:42 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
t=1793521301;
b=bSxtVO++MuO3kg1QsMoZ6FSF9bNvOXW5a23HAv8WwhXYbjPa2ASaK6t53AKBdHE9payf
xjo2LiAmBtGzIinohIC9GAAPCLTGH3N8UTGLxrGELS0DgzfZtrGxXDseB4vb4OcYVSNg3
lD0J2itheFx4/WU/PvFmC0LesmJ2gcIt8N2XPP5icA3uG5bGz9j0al6FOSuYyeCx3dbzG
4cWmxeAdUwxxw2AkqRLpwJZfi098og2a8ONMtnhMT5TVRSIPbXIc18m5hUMxjVX88g3SO
zkUeNkjYHPKbmx75GtVSPjsa7g2CdvDt7C7/y8rw/xnI63WqRD+FEt0J4Bfs5eU719Q==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1793521301;
h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:
X-Google-DKIM-Signature:X-Gm-Message-State:X-Gm-Gg:X-Received:
Received:Message-Id:In-Reply-To:References:From:Date:Subject:Fcc:
Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id:
List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
Precedence:MIME-Version:To:Cc;
bh=MyQC+H+vA82ndXqdaEiYGHjhep2Ezq3UNSewBr3mbD8=;
b=5FCIe8/XimDLcoum99smPsjsZXpKHLlnXkXo0Ddn+F0YmFSBPBUqTRo9O1g4GjetoRH0
BHVUsQ52T8DEZtNbLKcIC48q/1M58cCHp4cXuXpoCidyPm/PWmLFUY/0aJZZmQ6hcB/bE
2+Zj4e3D6E5n2y78aJwbbe0TLkj6DvIxJ+AR1wi6lOvAYYpVNyv45YEllNngAdwNcJt26
BNYBoEZzxyYjZQXDnZojlazW1v8V/YySsKV77T4G6PiYz1CdeAFzoc2nvFKmp6rxWXTtb
p4Z1jji+rRW3rhyIlb8omQe9LZYNGhu/mlKW4soxqo2GDTYKnuLugLClsYCsq+c/7ww==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org;
dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=CcGJBwVX;
dmarc=pass header.from=gmail.com;
spf=pass smtp.mailfrom=gmail.com;
arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
by smtp.subspace.kernel.org (Postfix) with ESMTP id 40967606A32D;
Sun, 1 Nov 2026 08:21:41 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=CcGJBwVX
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.160.171
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
t=1793521300;
b=5gDMAvq0SITtkmMKA+IxIrXyyDAE03oPAh8T3FAtjZ/LzNWvuBGy3+uxBdZreX+g7eth
l/U+I/Zv9vwEtwpfAmW2wg8G1A5T8WJPvKY9o5BlzT0ebsUSKA8OchjP4MTRgIxRUI6bN
i0+ghynQxCJqESNel37w6xipNVMPH0+kIBmvWDKHE8U0Jjm3K/PNDzPGm23SYkE2bfG2G
mLU+tfUsQimWnmyo6fbVj1MOMhMqAttRaJM1Zw8ri1l3HkUFUCoyHoN31ZOwLLznEW7yW
G1Iy8Y4F7iOoBwgLCGel/xBVoPH7pAxGuHP5nGzVWP3moowAP9fMSqShT+MwtESYFlQ==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1793521300;
h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
X-Gm-Message-State:X-Gm-Gg:X-Received:Received:Message-Id:In-Reply-To:
References:From:Date:Subject:Fcc:Content-Type:
Content-Transfer-Encoding:MIME-Version:To:Cc;
bh=MyQC+H+vA82ndXqdaEiYGHjhep2Ezq3UNSewBr3mbD8=;
b=QtuiMTkyVfbW/+PJTh2bQF9Ae3CJLzGBfxcAgGXM/FgR8IQAGKg0fmCR+MOFx/+kodhm
K5dYNogo7HTjV82I5h1T0L/lRgPT90KXYbWof7OeW0+A7fjPjqoUcgo+Z/8byTJt5A6XV
mZs/TfsIUzaWAgc3AEHOt6RxfmZ9Qsg+BeXYn7makccd1XmY+KGJfo0l6Iz8fhFuKXkD8
4/eH2195IKFp4kFgEy/476mfeRPbEJPiNwvg2pnj70HwXZsqdutHhgHjB3XbXJRc9IcNY
C7APDqulDcnTYSWxYTkdHWCoh/z+ljShCpYLuQBojKTFCgPAWqMUsCrO9ILy3yvdM/A==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org;
dmarc=pass header.from=gmail.com;
spf=pass smtp.mailfrom=gmail.com;
dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=CcGJBwVX;
arc=none smtp.remote-ip=209.85.160.171
X-Received: from mail-qt1-f171.google.com (mail-qt1-f171.google.com [209.85.160.171])
(using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)
key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
(No client certificate requested)
by smtp.subspace.kernel.org (Postfix) with ESMTPS id 07161606A324
for <git@vger.kernel.org>; Sun, 1 Nov 2026 08:21:39 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 07161606A324
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com
X-Received: by mail-qt1-f171.google.com with SMTP id d75a77b69052e-5364c951da4so20771541cf.1
for <git@vger.kernel.org>; Sun, 01 Nov 2026 01:21:39 -0700 (PDT)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20260707; t=1793521299; x=1794126099; darn=vger.kernel.org;
h=cc:to:mime-version:content-transfer-encoding:content-type:fcc
:subject:date:from:references:in-reply-to:message-id:from:to:cc
:subject:date:message-id:reply-to:content-type;
bh=MyQC+H+vA82ndXqdaEiYGHjhep2Ezq3UNSewBr3mbD8=;
b=CcGJBwVXiEIO/pAJXBWupPpXCwNlG1ijJFR12GNvpxN/0qtSrv7/56R30Tnge6bCRI
K+zbrd3oSm+GCvzeIEOrxloY9v7U2cyx7pkppwuJ5dgwOCQfX4fGxN3fS5sarpWZQEpl
21QcZHsKrWXIEUme31VEUEUVw436aLkRT4/s99TWoQmL1zYoZuWEvXdIsYo9G4zhuEz7
d3WHBGpowMth2Yb1lAqYQk1XjwOiCOV/djV3kRO9t5ycIzR6y/SljqRUH7CCfPsZDAAN
338/HKy7NZE6rUIWJa8h7sRLpD3a/mC9IUU050lTqeGnWiiAoSBfQVE51DpvU0VAAKvh
ysSw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20260707; t=1793521299; x=1794126099;
h=cc:to:mime-version:content-transfer-encoding:content-type:fcc
:subject:date:from:references:in-reply-to:message-id:x-gm-gg
:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to
:content-type;
bh=MyQC+H+vA82ndXqdaEiYGHjhep2Ezq3UNSewBr3mbD8=;
b=MMAM4NZCV0ClAMN5LGvey2pwfNtLu7DKUQxq2lwNDt7+EE2P1C/aGdF9ICfZ0mMvmf
/qOsUNePZ19UC1YIP2nW8XQ9njDhXyuSbwgOlKGxoxG0pgzIEKbfAZcXog+AXPddRfqW
h785ZemDZjIsP/d9VZCrJkF4ZZNYWSQ/Dk/Ze1hqH2e//5eAYYGuIqZcYNYRw0fQH8KS
4em3zBvDNYM3lzBSYlES4P881yBW06b8BnFe2PbUAeHhlXle3h4G8o2nOr7Mnoy4dNfK
/BGFLcuUdeTrMAwOS6o0UJXWeKWfZOWqBPIPV2Afhb9quysKXEmJkkg/Qa7Xz0JCnJqZ
jlJQ==
X-Gm-Message-State: AFq9FYJbKtntu3uU5zvgWaisJq5mmr/UiW7JoSOPNdhZCfJ3+96C42al
8MJFXL7/3ES+/LIOWqU44IWR9kXMnBGwFd0LctoQRwmdIUPLzM8m4ZfFVCssxpFxUkc=
X-Gm-Gg: AYBFou1uEbaGlP9ZYa+KK4zFKcCvD4qfpDLOGAd2NtGSt+uSKK/MRLPIxf3s8KLUJmn
NTS6ZH6h7Jsxs7Jn+1clBw/B4LBvoNKFMtrm2L9HmWAN+fGSxGHdqVCLtY/Fcp+sh+G5GpvR7D5
w7Wgx3it3mPDiCyhQq1tjGodpBQtf8p7do2YD+HD1PKS6p3VyBs4nmpe6SLgcP2ShiFE6n0ucUz
nssuVvui/W285YUBK9TeUFnBbu1qOWPWaDEkpmvKISbJG6i/o8S8a9KEs+K1n/hb+RXl63cPNvz
fSnlD8lCge88UNfgBjyvLNrkEdjMt/2K/eW1GjM1ZO5fUY/qKys5auLhRp3WWqoivuqFgrO6bEs
oK7iDSWrVfJAkmdbzH4MQGDNBs0Oez+m+dht0lWJGSVtmSWoflJhIWJOjbWwTL0S3eG392vOHdm
v8s7vUIesiCZlwS5Iy2TDzqG0s6iSd/M1FHxc8PGsS4ekdIvJ2Nrk5fDln5NX9XxIzSzA8cicQy
W4g6wG8mBilb1gqk3yIOSu5Lw/0I0GF+e1881Axwjlw2HMinJKnR5EGyhmt67CIjtZu3COXt6kT
x369UJT525qY73PGOZL9HvR23iqtjjNh
X-Received: by 2002:ac8:5f85:0:b0:535:fc2d:b7c2 with SMTP id d75a77b69052e-542b7044dc6mr116750331cf.33.1793521298973;
Sun, 01 Nov 2026 01:21:38 -0700 (PDT)
X-Received: from [127.0.0.1] ([20.119.79.64])
by smtp.gmail.com with ESMTPSA id d75a77b69052e-54312a5da26sm56330761cf.25.2026.11.01.01.21.37
(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
Sun, 01 Nov 2026 01:21:38 -0700 (PDT)
X-In-Reply-To: <pull.2456.git.git.1792437558.gitgitgadget@gmail.com>
X-Fcc: Sent
X-Mailing-List: git@vger.kernel.org
X-List-Post: <mailto:git@vger.kernel.org>
X-List-Help: <mailto:git+help@vger.kernel.org>
X-List-Subscribe: <mailto:git+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:git+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:git+owner@vger.kernel.org>
X-Precedence: list
X-Cc: Patrick Steinhardt <ps@pks.im>,
Harald Nordgren <haraldnordgren@gmail.com>