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

Re: MIME problem when using git format-patch / git am

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Apr 26, 2010, 01:49 UTC
Message-ID
<20100426014941.GA29220@progeny.tock>
In-Reply-To
<20100425233549.GA8737@triton>
Hi,
Øyvind A. Holm wrote:
| git commit -m "Initial commit" --allow-empty
| git tag firstrev
| echo First line >foo.txt
| git add foo.txt
| git commit -m "First commit without 8-bit chars"
| echo Second line >>foo.txt
| git commit -m "Second commit with © in first line of logmsg" -a
| echo Third line >>foo.txt
| git commit -m "Third commit with no 8-bit in first line`echo; echo but €uro further down`" -a
| echo Fourth line >>foo.txt
| git commit -m "Fourth commit with © in first line again" -a
| git format-patch firstrev
| git checkout -b patches firstrev
| git am 0*
| git log
[...]
|    Applying: =?UTF-8?q?Third=20commit=20with=20no=208-bit=20in=20first=20line
|    Applying: Fourth commit with © in first line again
On this machine, it’s even worse:
    =?UTF-8?q?Third=20commit=20with=20no=208-bit=20in=20first=20line
    
    =20but=20=E2=82=ACuro=20further=20down?=
    MIME-Version: 1.0
    Content-Type: text/plain; charset=UTF-8
    Content-Transfer-Encoding: 8bit

An encoded-word [1] is defined to be at most 75 characters long and not to contain whitespace. On the other hand, multiple encoded-words within a field are required to be separated by whitespace.

[1] http://tools.ietf.org/html/rfc2047

This leads to a question: what if one wants to include a word that quotes to more than 75 characters? How about more than 997 ASCII characters without whitespace? No can do.

Ideally, I would like to see git quoting single words, though I admit I have not seen how well various user agents cope with this.

Maybe this patch would give you some joy until then. Feel free to pick it up and take it somewhere more useful.

Thanks, Jonathan

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
diff --git a/pretty.c b/pretty.c
index d493cad..b822e24 100644
--- a/pretty.c
+++ b/pretty.c
@@ -131,7 +131,7 @@ needquote:
 		 * many programs do not understand this and just
 		 * leave the underscore in place.
 		 */
-		if (is_rfc2047_special(ch) || ch == ' ') {
+		if (is_rfc2047_special(ch) || ch == ' ' || ch == '\n') {
 			strbuf_add(sb, line + last, i - last);
 			strbuf_addf(sb, "=%02X", ch);
 			last = i + 1;
Previous: Øyvind A. HolmNext: Peter Krefting
Message 2 of 4 in “MIME problem when using git format-patch / git am”
  1. Øyvind A. HolmApr 25, 2010
  2. Jonathan NiederApr 26, 2010
  3. Peter KreftingApr 26, 2010
  4. Jonathan NiederApr 27, 2010

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.