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, 22:36 UTC
Message-ID
<128036e3-47b4-b7ae-034f-8d227a62729f@google.com>
In-Reply-To
<xmqqshszimrh.fsf@gitster.mtv.corp.google.com>
On 09/16/2016 01:59 PM, Junio C Hamano wrote:
>         if (mi->in_line_header->len) {
>                 /* we have read the beginning of one in-line header */
>                 if (line->len && isspace(*line->buf) &&
>                     !(mi->use_scissors && is_scissors_line(line))) {

Minor note: this means that the scissors check appears twice in the code, once here and once below (for the non-header case).

Show 5 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, ...);
(Sorry - should have also noticed this in your original e-mail.)

I'm concerned about what happens if check_header fails - we would then have some lines which need to be treated as log messages. (At least, they are currently treated that way.)

To treat them as log messages, we would need to convert them into UTF-8, which may possibly fail, so we would have to figure out how to clean up (we have to clean up because we cannot `die` immediately, at least to preserve the current behavior). Also, we are likely to detect such a failure only while processing a subsequent line - this non-"fail fast" currently is fine, but I'm concerned that it will hinder future development (especially when debugging).

Minor note: the buffer would also need to be more complicated (instead of the current single buffer), either:

o store newlines in that buffer (and we would need to remove all
   newlines before passing to check_header), or
o 2 buffers: one with newlines (for log messages) and one without (for
   check_header).

In light of the above (multiple scissors checks, late detection of failure, more complicated buffer), it seems clearer to me to just change the order of the checks (as in RFC/PATCH 1/3). This necessitates holding on to the old un-decoded buf and len, but this seems easier to me than the above.

>                 strbuf_reset(&mi->in_line_header);
>         }
> 	...
Previous: Junio C HamanoNext: Junio C Hamano
Message 20 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.