@matheusbsbs / matheus-bagliano / commits / 996e2d6ea2
Fork 0

Use =20 when rfc2047 encoding spaces.

Encode ' ' using '=20' even though rfc2047 allows using '_' for readability. Unfortunately, many programs do not understand this and just leave the underscore in place. Using '=20' seems to work better. [jc: with adjustment to t3901] Signed-off-by: Kristian Høgsberg <hoegsberg@gmail.com> Signed-off-by: Junio C Hamano <junkio@cox.net>

Kristian Høgsberg committed Jun 1, 2007 at 17:08 UTC 996e2d6ea2626f55a59e70ac7305a02ce0171814
2 files changed +12 -8
commit.c
+7 -3
@@ -511,12 +511,16 @@ static int add_rfc2047(char *buf, const char *line, int len,
511 bp += i;
512 for (i = 0; i < len; i++) {
513 unsigned ch = line[i] & 0xFF;
514 - if (is_rfc2047_special(ch)) {
514 + /*
515 + * We encode ' ' using '=20' even though rfc2047
516 + * allows using '_' for readability. Unfortunately,
517 + * many programs do not understand this and just
518 + * leave the underscore in place.
519 + */
520 + if (is_rfc2047_special(ch) || ch == ' ') {
521 sprintf(bp, "=%02X", ch);
522 bp += 3;
523 }
518 - else if (ch == ' ')
519 - *bp++ = '_';
524 else
525 *bp++ = ch;
526 }
t/t3901-i18n-patch.sh
+5 -5
@@ -13,7 +13,7 @@ check_encoding () {
13 while test "$i" -le $cnt
14 do
15 git format-patch --encoding=UTF-8 --stdout HEAD~$i..HEAD~$j |
16 - grep "^From: =?UTF-8?q?=C3=81=C3=A9=C3=AD_=C3=B3=C3=BA?=" &&
16 + grep "^From: =?UTF-8?q?=C3=81=C3=A9=C3=AD=20=C3=B3=C3=BA?=" &&
17 git-cat-file commit HEAD~$j |
18 case "$header" in
19 8859)
@@ -73,9 +73,9 @@ test_expect_success 'format-patch output (ISO-8859-1)' '
73 git format-patch --stdout master..HEAD^ >out-l1 &&
74 git format-patch --stdout HEAD^ >out-l2 &&
75 grep "^Content-Type: text/plain; charset=ISO-8859-1" out-l1 &&
76 - grep "^From: =?ISO-8859-1?q?=C1=E9=ED_=F3=FA?=" out-l1 &&
76 + grep "^From: =?ISO-8859-1?q?=C1=E9=ED=20=F3=FA?=" out-l1 &&
77 grep "^Content-Type: text/plain; charset=ISO-8859-1" out-l2 &&
78 - grep "^From: =?ISO-8859-1?q?=C1=E9=ED_=F3=FA?=" out-l2
78 + grep "^From: =?ISO-8859-1?q?=C1=E9=ED=20=F3=FA?=" out-l2
79 '
80
81 test_expect_success 'format-patch output (UTF-8)' '
@@ -84,9 +84,9 @@ test_expect_success 'format-patch output (UTF-8)' '
84 git format-patch --stdout master..HEAD^ >out-u1 &&
85 git format-patch --stdout HEAD^ >out-u2 &&
86 grep "^Content-Type: text/plain; charset=UTF-8" out-u1 &&
87 - grep "^From: =?UTF-8?q?=C3=81=C3=A9=C3=AD_=C3=B3=C3=BA?=" out-u1 &&
87 + grep "^From: =?UTF-8?q?=C3=81=C3=A9=C3=AD=20=C3=B3=C3=BA?=" out-u1 &&
88 grep "^Content-Type: text/plain; charset=UTF-8" out-u2 &&
89 - grep "^From: =?UTF-8?q?=C3=81=C3=A9=C3=AD_=C3=B3=C3=BA?=" out-u2
89 + grep "^From: =?UTF-8?q?=C3=81=C3=A9=C3=AD=20=C3=B3=C3=BA?=" out-u2
90 '
91
92 test_expect_success 'rebase (U/U)' '