Skip to content

Commit 996e2d6

Browse files
krhJunio C Hamano
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent cedb8d5 commit 996e2d6

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

commit.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -511,12 +511,16 @@ static int add_rfc2047(char *buf, const char *line, int len,
511511
bp += i;
512512
for (i = 0; i < len; i++) {
513513
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 == ' ') {
515521
sprintf(bp, "=%02X", ch);
516522
bp += 3;
517523
}
518-
else if (ch == ' ')
519-
*bp++ = '_';
520524
else
521525
*bp++ = ch;
522526
}

t/t3901-i18n-patch.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ check_encoding () {
1313
while test "$i" -le $cnt
1414
do
1515
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?=" &&
1717
git-cat-file commit HEAD~$j |
1818
case "$header" in
1919
8859)
@@ -73,9 +73,9 @@ test_expect_success 'format-patch output (ISO-8859-1)' '
7373
git format-patch --stdout master..HEAD^ >out-l1 &&
7474
git format-patch --stdout HEAD^ >out-l2 &&
7575
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 &&
7777
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
7979
'
8080

8181
test_expect_success 'format-patch output (UTF-8)' '
@@ -84,9 +84,9 @@ test_expect_success 'format-patch output (UTF-8)' '
8484
git format-patch --stdout master..HEAD^ >out-u1 &&
8585
git format-patch --stdout HEAD^ >out-u2 &&
8686
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 &&
8888
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
9090
'
9191

9292
test_expect_success 'rebase (U/U)' '

0 commit comments

Comments
 (0)