Re: [PATCH v4 2/4] imap-send: accept messages with Subject before Date
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Oct 30, 2026, 22:51 UTC
- Message-ID
- <xmqqqzh6u7i3.fsf@gitster.g>
- In-Reply-To
- <ad3158b3367d00fb78d2fa5a55b82d5f634c3d61.1793089879.git.gitgitgadget@gmail.com>
"Harald Nordgren via GitGitGadget" <gitgitgadget@gmail.com> writes:
Show 14 quoted lines
> +static bool has_required_headers(const char *line)
> +{
> + bool from = false, date = false, subject = false;
> +
> + while ((line = strchr(line, '\n')) && *++line != '\n') {
> + if (starts_with(line, "From: "))
> + from = true;
> + else if (starts_with(line, "Date: "))
> + date = true;
> + else if (starts_with(line, "Subject: "))
> + subject = true;
> + }
> + return from && date && subject;
> +}The above assumes that an empty line that denotes the end of the header can be detected by looking for '\n\n' in the line[]. So this may be scanning thru to the end of the message including the body, because each and every line ends with CRLF and there is no two consecutive LF appearing in the line.
I admit that it was eons ago I read RFCs on IMAP (like RFC 2060), but I recall that its definition explicitly called for CRLF line endings, and existing code in imap-send.c before these patches seems to expect that it is reading CRLF delimited lines.
I didn't look at other parts of the series, but this one stood out.