]>
diplodocus.org Git - nmh/blob - test/mhbuild/test-header-encode
2 ######################################################
4 # Test encoding headers according to RFC 2047
6 ######################################################
10 if test -z " ${MH_OBJ_DIR} " ; then
11 srcdir
= `dirname " $0 "` / ..
/ ..
12 MH_OBJ_DIR
= `cd " $srcdir " && pwd` ; export MH_OBJ_DIR
15 .
" ${MH_OBJ_DIR} /test/common.sh"
18 testname
= " ${MH_TEST_DIR} /$$"
21 # We're going to hardcode UTF-8 for this test.
24 LC_ALL
= en_US.UTF
-8 ; export LC_ALL
27 # Basic test of encoding a short subject
29 cat > " ${testname} .basic.actual" <<EOF
30 From: Mr Foo Bar <foobar@example.com>
31 To: Somebody <somebody@example.com>
32 Subject: This is ä test
37 cat > " ${testname} .basic.expected" <<EOF
38 From: Mr Foo Bar <foobar@example.com>
39 To: Somebody <somebody@example.com>
40 Subject: =?UTF-8?Q?This_is_=C3=A4_test?=
42 Content-Type: text/plain; charset="us-ascii"
47 mhbuild
" ${testname} .basic.actual"
49 check
" ${testname} .basic.actual" " ${testname} .basic.expected" 'keep first'
52 # Make sure we can undo the encoding
55 run_test
'eval fmttest -outsize max -format "%(decode{subject})" -message -file " ${testname} .basic.actual"' 'This is ä test'
57 rm -f " ${testname} .basic.actual"
60 # Basic test of encoding a short subject, but with base64
62 cat > " ${testname} .basic.actual" <<EOF
63 From: Mr Foo Bar <foobar@example.com>
64 To: Somebody <somebody@example.com>
65 Subject: This is ä test
70 cat > " ${testname} .basic.expected" <<EOF
71 From: Mr Foo Bar <foobar@example.com>
72 To: Somebody <somebody@example.com>
73 Subject: =?UTF-8?B?VGhpcyBpcyDDpCB0ZXN0?=
75 Content-Type: text/plain; charset="us-ascii"
80 mhbuild
-headerencoding base64
" ${testname} .basic.actual"
82 check
" ${testname} .basic.actual" " ${testname} .basic.expected" 'keep first'
84 run_test
'eval fmttest -outsize max -format "%(decode{subject})" -message -file " ${testname} .basic.actual"' 'This is ä test'
86 rm -f " ${testname} .basic.actual"
89 # Have a subject that will pick base64 as the shorter encoding
92 cat > " ${testname} .autopick.actual" <<EOF
93 From: Mr Foo Bar <foobar@example.com>
94 To: Somebody <somebody@example.com>
95 Subject: This is ä tëst©
100 cat > " ${testname} .autopick.expected" <<EOF
101 From: Mr Foo Bar <foobar@example.com>
102 To: Somebody <somebody@example.com>
103 Subject: =?UTF-8?B?VGhpcyBpcyDDpCB0w6tzdMKp?=
105 Content-Type: text/plain; charset="us-ascii"
110 mhbuild
" ${testname} .autopick.actual"
112 check
" ${testname} .autopick.actual" " ${testname} .autopick.expected" 'keep first'
114 run_test
'eval fmttest -outsize max -format "%(decode{subject})" -message -file " ${testname} .autopick.actual"' 'This is ä tëst©'
116 rm -f " ${testname} .basic.autopick"
119 # Tests using longer subject lines.
122 cat > " ${testname} .longsubject1.actual" <<EOF
123 From: Mr Foo Bar <foobar@example.com>
124 To: Somebody <somebody@example.com>
125 Subject: This is ä tëst of a rather long sübject line; will it overflow
126 the line length? I sure hope thät ='s and "'s are encoded properly. Will
129 This is a test of a very long subject line.
132 cat > " ${testname} .longsubject1.expected" <<EOF
133 From: Mr Foo Bar <foobar@example.com>
134 To: Somebody <somebody@example.com>
135 Subject: =?UTF-8?Q?This_is_=C3=A4_t=C3=ABst_of_a_rather_long_s=C3=BCbject_?=
136 =?UTF-8?Q?line;_will_it_overflow_the_line_length=3F__I_sure_hope_?=
137 =?UTF-8?Q?th=C3=A4t_=3D's_and_"'s_are_encoded_properly.__Will_the?=
140 Content-Type: text/plain; charset="us-ascii"
142 This is a test of a very long subject line.
145 mhbuild
" ${testname} .longsubject1.actual"
147 check
" ${testname} .longsubject1.actual" " ${testname} .longsubject1.expected" 'keep first'
149 run_test
'eval fmttest -outsize max -format "%(putlit(decode(trim{subject})))" -message -file " ${testname} .longsubject1.actual"' "This is ä tëst of a rather long sübject line; will it overflow the line length? I sure hope thät ='s and \" 's are encoded properly. Will they be?"
151 rm -f " ${testname} .longsubject1.actual"
154 # Test a longer line with base64 encoding
157 cat > " ${testname} .longsubject2.actual" <<EOF
158 From: Mr Foo Bar <foobar@example.com>
159 To: Somebody <somebody@example.com>
160 Subject: This is ä tëst øf ä räthër løng sübjëct line; will it øvërfløw
161 the line length? I sure hope thät ='s and "'s are encoded properly. Will
164 This is a test of a very long subject line using base64.
167 cat > " ${testname} .longsubject2.expected" <<EOF
168 From: Mr Foo Bar <foobar@example.com>
169 To: Somebody <somebody@example.com>
170 Subject: =?UTF-8?B?VGhpcyBpcyDDpCB0w6tzdCDDuGYgw6QgcsOkdGjDq3IgbMO4bmcg?=
171 =?UTF-8?B?c8O8YmrDq2N0IGxpbmU7IHdpbGwgaXQgw7h2w6tyZmzDuHcgdGhl?=
172 =?UTF-8?B?IGxpbmUgbGVuZ3RoPyAgSSBzdXJlIGhvcGUgdGjDpHQgPSdzIGFu?=
173 =?UTF-8?B?ZCAiJ3MgYXJlIGVuY29kZWQgcHJvcGVybHkuICBXaWxsIHRoZXkg?=
176 Content-Type: text/plain; charset="us-ascii"
178 This is a test of a very long subject line using base64.
181 mhbuild
" ${testname} .longsubject2.actual"
183 check
" ${testname} .longsubject2.actual" " ${testname} .longsubject2.expected" 'keep first'
185 run_test
'eval fmttest -outsize max -format "%(putlit(decode(trim{subject})))" -message -file " ${testname} .longsubject2.actual"' "This is ä tëst øf ä räthër løng sübjëct line; will it øvërfløw the line length? I sure hope thät ='s and \" 's are encoded properly. Will they be?"