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

Re: [PATCH 3/3] format-patch: rfc2047-encode newlines in headers

From
Jeff King <peff@peff.net>
Date
Feb 24, 2011, 07:15 UTC
Message-ID
<20110224071534.GC16550@sigill.intra.peff.net>
In-Reply-To
<7vhbbu7792.fsf@alter.siamese.dyndns.org>
On Wed, Feb 23, 2011 at 01:47:53PM -0800, Junio C Hamano wrote:
Show 10 quoted lines
> Jeff King <peff@peff.net> writes:
> 
> > These should generally never happen, as we already
> > concatenate multiples in subjects into a single line. But
> > let's be defensive, since not encoding them means we will
> > output malformed headers.
> 
> In this particular case, wouldn't it be more conservative and defensive to
> produce malformed headers so that the patch won't leave the
> originator?

No. If you go back to xzer's original mail, the malformed headers didn't cause messages not to be sent. They just resulted in corrupted and missing data on the receiver side. I don't think we can rely on any MUA or MTA having a particular behavior for malformed mail. Some of them may complain, but many won't.

> I have a suspicion that mailinfo would choke on the output of this
> one, even though I didn't try.

Actually, it does quite well. Without "-k", mailinfo turns it into a single line, which is what I would expect. With "-k", the info file contains:

  Author: Jeff King
  Email: peff@peff.net
  Subject: this is a long
  Subject: subject line with
  Subject: many lines in it
  Date: Wed, 23 Feb 2011 11:30:43 -0500
which "git am" turns back into the original multi-line subject.

So I think it's definitely the right thing to do. Not only does it avoid us generating malformed mail, but because existing mailinfo handles it sanely, it makes it easy to do a "preserve-newlines" patch on top (which I'm still not sure is a great idea, but I can see the use in certain circumstances).

-Peff
Previous: Junio C HamanoNext: xzer
Message 9 of 15 in “generate a valid rfc2047 mail header for multi-line subject.”
  1. generate a valid rfc2047 mail header for multi-line subject.xzer, Feb 14, 2011
  2. Junio C HamanoFeb 22, 2011
  3. Jeff KingFeb 23, 2011
  4. Jeff KingFeb 23, 2011
  5. 1/3 strbuf: add fixed-length version of add_wrapped_textJeff King, Feb 23, 2011
  6. 2/3 format-patch: wrap long header linesJeff King, Feb 23, 2011
  7. 3/3 format-patch: rfc2047-encode newlines in headersJeff King, Feb 23, 2011
  8. Junio C HamanoFeb 23, 2011
  9. Jeff KingFeb 24, 2011
  10. xzerFeb 23, 2011
  11. Jeff KingFeb 23, 2011
  12. Junio C HamanoFeb 23, 2011
  13. Jeff KingFeb 24, 2011
  14. xzerFeb 23, 2011
  15. Junio C HamanoFeb 23, 2011

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.