Skip to content

Commit 688ba09

Browse files
committed
Merge branch 'ks/maint-1.6.0-mailinfo-folded' into maint-1.6.0
* ks/maint-1.6.0-mailinfo-folded: mailinfo: tests for RFC2047 examples mailinfo: add explicit test for mails like '<[email protected]> (A U Thor)' mailinfo: 'From:' header should be unfold as well mailinfo: correctly handle multiline 'Subject:' header
2 parents 3e186ef + c32815f commit 688ba09

22 files changed

+229
-10
lines changed

builtin-mailinfo.c

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -430,13 +430,6 @@ static struct strbuf *decode_b_segment(const struct strbuf *b_seg)
430430
c -= 'a' - 26;
431431
else if ('0' <= c && c <= '9')
432432
c -= '0' - 52;
433-
else if (c == '=') {
434-
/* padding is almost like (c == 0), except we do
435-
* not output NUL resulting only from it;
436-
* for now we just trust the data.
437-
*/
438-
c = 0;
439-
}
440433
else
441434
continue; /* garbage */
442435
switch (pos++) {
@@ -514,7 +507,25 @@ static int decode_header_bq(struct strbuf *it)
514507
rfc2047 = 1;
515508

516509
if (in != ep) {
517-
strbuf_add(&outbuf, in, ep - in);
510+
/*
511+
* We are about to process an encoded-word
512+
* that begins at ep, but there is something
513+
* before the encoded word.
514+
*/
515+
char *scan;
516+
for (scan = in; scan < ep; scan++)
517+
if (!isspace(*scan))
518+
break;
519+
520+
if (scan != ep || in == it->buf) {
521+
/*
522+
* We should not lose that "something",
523+
* unless we have just processed an
524+
* encoded-word, and there is only LWS
525+
* before the one we are about to process.
526+
*/
527+
strbuf_add(&outbuf, in, ep - in);
528+
}
518529
in = ep;
519530
}
520531
/* E.g.
@@ -860,6 +871,7 @@ static void handle_info(void)
860871
}
861872
output_header_lines(fout, "Subject", hdr);
862873
} else if (!memcmp(header[i], "From", 4)) {
874+
cleanup_space(hdr);
863875
handle_from(hdr);
864876
fprintf(fout, "Author: %s\n", name.buf);
865877
fprintf(fout, "Email: %s\n", email.buf);

t/t5100-mailinfo.sh

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ test_expect_success 'split sample box' \
1111
'git mailsplit -o. ../t5100/sample.mbox >last &&
1212
last=`cat last` &&
1313
echo total is $last &&
14-
test `cat last` = 11'
14+
test `cat last` = 13'
1515

1616
for mail in `echo 00*`
1717
do
@@ -25,6 +25,28 @@ do
2525
diff ../t5100/info$mail info$mail"
2626
done
2727

28+
29+
test_expect_success 'split box with rfc2047 samples' \
30+
'mkdir rfc2047 &&
31+
git mailsplit -orfc2047 "$TEST_DIRECTORY"/t5100/rfc2047-samples.mbox \
32+
>rfc2047/last &&
33+
last=`cat rfc2047/last` &&
34+
echo total is $last &&
35+
test `cat rfc2047/last` = 11'
36+
37+
for mail in `echo rfc2047/00*`
38+
do
39+
test_expect_success "mailinfo $mail" '
40+
git mailinfo -u $mail-msg $mail-patch <$mail >$mail-info &&
41+
echo msg &&
42+
test_cmp "$TEST_DIRECTORY"/t5100/empty $mail-msg &&
43+
echo patch &&
44+
test_cmp "$TEST_DIRECTORY"/t5100/empty $mail-patch &&
45+
echo info &&
46+
test_cmp "$TEST_DIRECTORY"/t5100/rfc2047-info-$(basename $mail) $mail-info
47+
'
48+
done
49+
2850
test_expect_success 'respect NULs' '
2951
3052
git mailsplit -d3 -o. ../t5100/nul-plain &&

t/t5100/empty

Whitespace-only changes.

t/t5100/info0012

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Author: Dmitriy Blinov
2+
3+
Subject: Изменён список пакетов необходимых для сборки
4+
Date: Wed, 12 Nov 2008 17:54:41 +0300
5+

t/t5100/info0013

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Author: A U Thor
2+
3+
Subject: a patch
4+
Date: Fri, 9 Jun 2006 00:44:16 -0700
5+

t/t5100/msg0012

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
textlive-* исправлены на texlive-*
2+
docutils заменён на python-docutils
3+
4+
Действительно, оказалось, что rest2web вытягивает за собой
5+
python-docutils. В то время как сам rest2web не нужен.
6+
7+
Signed-off-by: Dmitriy Blinov <[email protected]>

t/t5100/msg0013

Whitespace-only changes.

t/t5100/patch0012

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
---
2+
howto/build_navy.txt | 6 +++---
3+
1 files changed, 3 insertions(+), 3 deletions(-)
4+
5+
diff --git a/howto/build_navy.txt b/howto/build_navy.txt
6+
index 3fd3afb..0ee807e 100644
7+
--- a/howto/build_navy.txt
8+
+++ b/howto/build_navy.txt
9+
@@ -119,8 +119,8 @@
10+
- libxv-dev
11+
- libusplash-dev
12+
- latex-make
13+
- - textlive-lang-cyrillic
14+
- - textlive-latex-extra
15+
+ - texlive-lang-cyrillic
16+
+ - texlive-latex-extra
17+
- dia
18+
- python-pyrex
19+
- libtool
20+
@@ -128,7 +128,7 @@
21+
- sox
22+
- cython
23+
- imagemagick
24+
- - docutils
25+
+ - python-docutils
26+
27+
#. на машине dinar: добавить свой открытый ssh-ключ в authorized_keys2 пользователя ddev
28+
#. на своей машине: отредактировать /etc/sudoers (команда ``visudo``) примерно следующим образом::
29+
--
30+
1.5.6.5

t/t5100/patch0013

Whitespace-only changes.

t/t5100/rfc2047-info-0001

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Author: Keith Moore
2+
3+
Subject: If you can read this you understand the example.
4+

0 commit comments

Comments
 (0)