git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] Ignore blank lines among this inbody headers.

From
Eric W. Biederman <ebiederm@xmission.com>
Date
Jun 12, 2006, 18:45 UTC
Message-ID
<m17j3m6wmw.fsf_-_@ebiederm.dsl.xmission.com>
In-Reply-To
<Pine.LNX.4.64.0606111735440.5498@g5.osdl.org>

This is a fix for a regression introduced in: 8b4525fb3c6d79bd3a64b8f441237a4095db4e22.

When I refactored the inbody header parsing into a state machine I failed to see the logic that skipped multiple leading spaces if they are present. I think I assumed that logic was just there to skip the initial blank line between the mail headers and the body.

This restores that behaviour and since we ignore all leading blank lines
in commit messages now this code removes the special case for the blank
line between the mail headers and the body.
---
 mailinfo.c |   24 ++++++++++++++++--------
 1 files changed, 16 insertions(+), 8 deletions(-)
diff --git a/mailinfo.c b/mailinfo.c
index 5b6c215..3696d61 100644
--- a/mailinfo.c
+++ b/mailinfo.c
@@ -229,6 +229,14 @@ static int is_multipart_boundary(const c
 	return (!memcmp(line, multipart_boundary, multipart_boundary_len));
 }
 
+static int is_blank(char *line)
+{
+	char *ch;
+	for (ch = line; isspace(*ch); ch++)
+		;
+	return *ch == '\0';
+}
+
 static int eatspace(char *line)
 {
 	int len = strlen(line);
@@ -243,7 +251,7 @@ #define SEEN_SUBJECT 04
 #define SEEN_BOGUS_UNIX_FROM 010
 #define SEEN_PREFIX  020
 
-/* First lines of body can have From:, Date:, and Subject: */
+/* First lines of body can have From:, Date:, and Subject: or be blank */
 static void handle_inbody_header(int *seen, char *line)
 {
 	if (!memcmp(">From", line, 5) && isspace(line[5])) {
@@ -279,6 +287,10 @@ static void handle_inbody_header(int *se
 			return;
 		}
 	}
+	if (isspace(line[0])) {
+		if (!(*seen & SEEN_PREFIX) && is_blank(line))
+			return;
+	}
 	*seen |= SEEN_PREFIX;
 }
 
@@ -420,9 +432,7 @@ static int read_one_header_line(char *li
 		if (fgets(line + ofs, sz - ofs, in) == NULL)
 			break;
 		len = eatspace(line + ofs);
-		if (len == 0)
-			break;
-		if (!is_rfc2822_header(line)) {
+		if ((len == 0) || !is_rfc2822_header(line)) {
 			/* Re-add the newline */
 			line[ofs + len] = '\n';
 			line[ofs + len + 1] = '\0';
@@ -762,10 +772,8 @@ static void handle_body(void)
 {
 	int seen = 0;
 
-	if (line[0] || fgets(line, sizeof(line), stdin) != NULL) {
-		handle_commit_msg(&seen);
-		handle_patch();
-	}
+	handle_commit_msg(&seen);
+	handle_patch();
 	fclose(patchfile);
 	if (!patch_lines) {
 		fprintf(stderr, "No patch found\n");
-- 
1.4.0.rc2.g5e3a6
Previous: Eric W. BiedermanNext: Eric W. Biederman
Message 5 of 13 in “git-applymbox broken?”
  1. Linus TorvaldsJun 11, 2006
  2. Eric W. BiedermanJun 11, 2006
  3. Linus TorvaldsJun 12, 2006
  4. Eric W. BiedermanJun 12, 2006
  5. Ignore blank lines among this inbody headers.Eric W. Biederman, Jun 12, 2006
  6. Ignore blank lines among this inbody headersEric W. Biederman, Jun 12, 2006
  7. Eric W. BiedermanJun 12, 2006
  8. Linus TorvaldsJun 12, 2006
  9. Don't parse any headers in the real body of an email message.Eric W. Biederman, Jun 12, 2006
  10. Eric W. BiedermanJun 12, 2006
  11. Johannes SchindelinJun 12, 2006
  12. Randy.DunlapJun 12, 2006
  13. Ryan AndersonJun 13, 2006

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.