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

Re: [RFC/PATCH 3/3] mailinfo: handle in-body header continuations

From
JTJonathan Tan <jonathantanmy@google.com>
Date
Sep 16, 2016, 20:49 UTC
Message-ID
<1b392241-461e-3b87-400d-70d66903e3d7@google.com>
In-Reply-To
<xmqq8turk3aw.fsf@gitster.mtv.corp.google.com>
On 09/16/2016 01:17 PM, Junio C Hamano wrote:
Show 9 quoted lines
> In other words, wouldn't something like the illustration at the end
> of this message sufficient?  If the body consists solely of in-body
> header without any patch or patchbreak, we may reach EOF with
> something in mi->in_line_header buffer and nothing in
> mi->log_message and without this function getting any chance to
> return 1, so a careful caller may want to flush in_line_header, but
> the overall result of the mailinfo subsystem in such a case would be
> an error ("you didn't have any patch or a message?"), so it may not
> matter too much.

Noted. (This was one of my concerns - that the caller should, but did not, flush.)

Show 7 quoted lines
> What am I missing?
>
> handle_commit_msg(...)
> {
> 	if (mi->in_line_header->len) {
> 		/* we have read the beginning of one in-line header */
> 		if (line->len && isspace(*line->buf))
This would mean that a message like the following:
   From: Me <me@example.com>
     -- 8< -- this scissors line will be treated as part of "From"
would have its scissors line treated as a header.

The main reason why I reordered the checks (in RFC/PATCH 1/3) is to avoid this (treating a scissors line with an initial space immediately following an in-body header as part of a header).

(If this is not a concern then yes, I agree that the way you described is simpler and better.)

Show 52 quoted lines
> 			append to mi->in_line_header strbuf;
>                         return 0;
> 		/* otherwise we know mi->in_line_header is now complete */
> 		check_header(mi, mi->in_line_header, ...);
> 		strbuf_reset(&mi->in_line_header);
> 	}
>
> 	if (mi->header_stage && (it is a blank line))
> 		return 0;
>
> 	if (mi->use_inbody_headers && mi->header_stage &&
> 	    (the line looks like beginning of 2822 header)) {
> 		strbuf_addbuf(&mi->in_line_header, line);
> 		return 0;
> 	}
>         /* otherwise we are no longer looking at headers */
>         mi->header_stage = 0;
>
> 	/* normalize the log message to UTF-8. */
> 	if (convert_to_utf8(mi, line, mi->charset.buf))
> 		return 0; /* mi->input_error already set */
>
> 	if (mi->use_scissors && is_scissors_line(line)) {
> 		int i;
>
> 		strbuf_setlen(&mi->log_message, 0);
> 		mi->header_stage = 1;
>
> 		/*
> 		 * We may have already read "secondary headers"; purge
> 		 * them to give ourselves a clean restart.
> 		 */
> 		for (i = 0; header[i]; i++) {
> 			if (mi->s_hdr_data[i])
> 				strbuf_release(mi->s_hdr_data[i]);
> 			mi->s_hdr_data[i] = NULL;
> 		}
> 		return 0;
> 	}
>
> 	if (patchbreak(line)) {
> 		if (mi->message_id)
> 			strbuf_addf(&mi->log_message,
> 				    "Message-Id: %s\n", mi->message_id);
> 		return 1;
> 	}
>
> 	strbuf_addbuf(&mi->log_message, line);
> 	return 0;
> }
>
>
Previous: Junio C HamanoNext: Junio C Hamano
Message 18 of 24 in “sequencer: support folding in rfc2822 footer”
  1. sequencer: support folding in rfc2822 footerJonathan Tan, Sep 2, 2016
  2. Junio C HamanoSep 3, 2016
  3. Jonathan TanSep 6, 2016
  4. Jonathan TanSep 6, 2016
  5. Jeff KingSep 7, 2016
  6. 0/3 handle multiline in-body headersJonathan Tan, Sep 16, 2016
  7. 1/3 mailinfo: refactor commit message processingJonathan Tan, Sep 16, 2016
  8. Junio C HamanoSep 16, 2016
  9. Jeff KingSep 16, 2016
  10. 2/3 mailinfo: correct malformed test exampleJonathan Tan, Sep 16, 2016
  11. Junio C HamanoSep 16, 2016
  12. Jonathan TanSep 16, 2016
  13. Junio C HamanoSep 16, 2016
  14. Jonathan TanSep 17, 2016
  15. Junio C HamanoSep 17, 2016
  16. 3/3 mailinfo: handle in-body header continuationsJonathan Tan, Sep 16, 2016
  17. Junio C HamanoSep 16, 2016
  18. Jonathan TanSep 16, 2016
  19. Junio C HamanoSep 16, 2016
  20. Jonathan TanSep 16, 2016
  21. Junio C HamanoSep 16, 2016
  22. Jonathan TanSep 17, 2016
  23. Jeff KingSep 16, 2016
  24. Junio C HamanoSep 16, 2016

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.