[PATCH v5 4/4] imap-send: match header names case insensitively
- From
Harald Nordgren via GitGitGadget <gitgitgadget@gmail.com>
- Date
- Nov 1, 2026, 08:21 UTC
- Message-ID
- <e7d1d7cd72563a8109f94137236cab3d0157d39f.1793521297.git.gitgitgadget@gmail.com>
- In-Reply-To
- <pull.2456.v5.git.git.1793521297.gitgitgadget@gmail.com>
From: Harald Nordgren <haraldnordgren@gmail.com>
imap-send says "no messages found to send" for a message whose headers are spelled "from:", "date:" or "subject:", although RFC 5322 treats header field names as case insensitive. Match the three names in any case.
Signed-off-by: Harald Nordgren <haraldnordgren@gmail.com> --- imap-send.c | 6 +++--- t/t9001-send-email.sh | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 3 deletions(-)
diff --git a/imap-send.c b/imap-send.c index d7172078c3..1b5850a80e 100644 --- a/imap-send.c +++ b/imap-send.c @@ -1463,11 +1463,11 @@ static bool has_required_headers(const char *line) while ((line = strchr(line, '\n')) && *++line != '\n' && !starts_with(line, "\r\n")) { - if (starts_with(line, "From: ")) + if (istarts_with(line, "From: ")) from = true; - else if (starts_with(line, "Date: ")) + else if (istarts_with(line, "Date: ")) date = true; - else if (starts_with(line, "Subject: ")) + else if (istarts_with(line, "Subject: ")) subject = true; } return from && date && subject; diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh index 5e03b350c1..37d21424c9 100755 --- a/t/t9001-send-email.sh +++ b/t/t9001-send-email.sh @@ -2914,4 +2914,19 @@ test_expect_success $PREREQ '--imap-sent-folder stores a copy of the sent patch' test_grep "(1/1) done" err ' +test_expect_success $PREREQ 'imap-send matches header names in any case' ' + test_config imap.tunnel ./fake-imap-server && + cat >lowercase.mbox <<-\EOF && + From mboxrd@z Thu Jan 1 00:00:00 1970 + from: Example <from@example.com> + date: Thu, 1 Jan 1970 00:00:00 +0000 + subject: [PATCH] lowercase headers + + body + EOF + git imap-send --folder=INBOX <lowercase.mbox 2>err && + test_grep "^Sending 1 message to INBOX folder" err && + test_grep "(1/1) done" err +' + test_done
-- gitgitgadget