]> diplodocus.org Git - nmh/blob - test/mhbuild/test-cte
Don't need to `else' after done() at end of then-block.
[nmh] / test / mhbuild / test-cte
1 #!/bin/sh
2 #########################################################
3 #
4 # Test the use of explicit Content-Transfer-Encoding tags
5 #
6 #########################################################
7
8 if test -z "${MH_OBJ_DIR}"; then
9 srcdir=`dirname "$0"`/../..
10 MH_OBJ_DIR=`cd "$srcdir" && pwd`; export MH_OBJ_DIR
11 fi
12
13 . "$MH_OBJ_DIR/test/common.sh"
14
15 setup_test
16
17 set -e
18
19 require_locale en_US.UTF-8 en_US.UTF8 en_US.utf-8 en_US.utf8
20
21 draft="$MH_TEST_DIR/$$.draft"
22 backup="${MH_TEST_DIR}/`mhparam sbackup`$$.draft.orig"
23 expected="$MH_TEST_DIR/$$.expected"
24
25 #
26 # Force some text to be quoted-printable
27 #
28
29 cat > "$draft" <<EOF
30 To: Mr Test <mrtest@example.com>
31 cc:
32 Fcc: +outbox
33 ------
34 #<text/plain *qp
35 This is a test of a message with a shørt line.
36 EOF
37
38 cat > "$expected" <<EOF
39 To: Mr Test <mrtest@example.com>
40 cc:
41 Fcc: +outbox
42 MIME-Version: 1.0
43 Content-Type: text/plain; charset="UTF-8"
44 Content-Transfer-Encoding: quoted-printable
45
46 This is a test of a message with a sh=C3=B8rt line.
47 EOF
48
49 run_prog mhbuild "$draft"
50 check "$draft" "$expected"
51
52 #
53 # Force some text to be base64, to test out the encoder. Try at different
54 # line lengths to check out the padding on the routines to convert LF to
55 # CR LF. The current implementation reads in using a 3 byte buffer, so make
56 # sure we catch all of those cases.
57 #
58
59 cat > "$draft" <<EOF
60 To: Mr Test <mrtest@example.com>
61 cc:
62 Fcc: +outbox
63 ------
64 #<text/plain *b64
65 This is a test of a message with a shørt line.
66 EOF
67
68 cat > "$expected" <<EOF
69 To: Mr Test <mrtest@example.com>
70 cc:
71 Fcc: +outbox
72 MIME-Version: 1.0
73 Content-Type: text/plain; charset="UTF-8"
74 Content-Transfer-Encoding: base64
75
76 VGhpcyBpcyBhIHRlc3Qgb2YgYSBtZXNzYWdlIHdpdGggYSBzaMO4cnQgbGluZS4NCg==
77 EOF
78
79 run_prog mhbuild "$draft"
80 check "$draft" "$expected"
81
82 cat > "$draft" <<EOF
83 To: Mr Test <mrtest@example.com>
84 cc:
85 Fcc: +outbox
86 ------
87 #<text/plain *b64
88 This is a test of a mëssage with a shørt line.
89 EOF
90
91 cat > "$expected" <<EOF
92 To: Mr Test <mrtest@example.com>
93 cc:
94 Fcc: +outbox
95 MIME-Version: 1.0
96 Content-Type: text/plain; charset="UTF-8"
97 Content-Transfer-Encoding: base64
98
99 VGhpcyBpcyBhIHRlc3Qgb2YgYSBtw6tzc2FnZSB3aXRoIGEgc2jDuHJ0IGxpbmUuDQo=
100 EOF
101
102 run_prog mhbuild "$draft"
103 check "$draft" "$expected"
104
105 cat > "$draft" <<EOF
106 To: Mr Test <mrtest@example.com>
107 cc:
108 Fcc: +outbox
109 ------
110 #<text/plain *b64
111 This is a test of a mëssäge with a shørt line.
112 EOF
113
114 cat > "$expected" <<EOF
115 To: Mr Test <mrtest@example.com>
116 cc:
117 Fcc: +outbox
118 MIME-Version: 1.0
119 Content-Type: text/plain; charset="UTF-8"
120 Content-Transfer-Encoding: base64
121
122 VGhpcyBpcyBhIHRlc3Qgb2YgYSBtw6tzc8OkZ2Ugd2l0aCBhIHNow7hydCBsaW5lLg0K
123 EOF
124
125 run_prog mhbuild "$draft"
126 check "$draft" "$expected"
127
128 cat > "$draft" <<EOF
129 To: Mr Test <mrtest@example.com>
130 cc:
131 Fcc: +outbox
132 ------
133 #<text/plain *b64
134 This is a test of a message with a shørt line.
135 This is a second line.
136 EOF
137
138 cat > "$expected" <<EOF
139 To: Mr Test <mrtest@example.com>
140 cc:
141 Fcc: +outbox
142 MIME-Version: 1.0
143 Content-Type: text/plain; charset="UTF-8"
144 Content-Transfer-Encoding: base64
145
146 VGhpcyBpcyBhIHRlc3Qgb2YgYSBtZXNzYWdlIHdpdGggYSBzaMO4cnQgbGluZS4NClRoaXMgaXMg
147 YSBzZWNvbmQgbGluZS4NCg==
148 EOF
149
150 run_prog mhbuild "$draft"
151 check "$draft" "$expected"
152
153 cat > "$draft" <<EOF
154 To: Mr Test <mrtest@example.com>
155 cc:
156 Fcc: +outbox
157 ------
158 #<text/plain *b64
159 This is a test of a mëssage with a shørt line.
160 This is a second line.
161 EOF
162
163 cat > "$expected" <<EOF
164 To: Mr Test <mrtest@example.com>
165 cc:
166 Fcc: +outbox
167 MIME-Version: 1.0
168 Content-Type: text/plain; charset="UTF-8"
169 Content-Transfer-Encoding: base64
170
171 VGhpcyBpcyBhIHRlc3Qgb2YgYSBtw6tzc2FnZSB3aXRoIGEgc2jDuHJ0IGxpbmUuDQpUaGlzIGlz
172 IGEgc2Vjb25kIGxpbmUuDQo=
173 EOF
174
175 run_prog mhbuild "$draft"
176 check "$draft" "$expected"
177
178 cat > "$draft" <<EOF
179 To: Mr Test <mrtest@example.com>
180 cc:
181 Fcc: +outbox
182 ------
183 #<text/plain *b64
184 This is a test of a mëssäge with a shørt line.
185 This is a second line.
186 EOF
187
188 cat > "$expected" <<EOF
189 To: Mr Test <mrtest@example.com>
190 cc:
191 Fcc: +outbox
192 MIME-Version: 1.0
193 Content-Type: text/plain; charset="UTF-8"
194 Content-Transfer-Encoding: base64
195
196 VGhpcyBpcyBhIHRlc3Qgb2YgYSBtw6tzc8OkZ2Ugd2l0aCBhIHNow7hydCBsaW5lLg0KVGhpcyBp
197 cyBhIHNlY29uZCBsaW5lLg0K
198 EOF
199
200 run_prog mhbuild "$draft"
201 check "$draft" "$expected"
202
203 cat > "$draft" <<EOF
204 To: Mr Test <mrtest@example.com>
205 cc:
206 Fcc: +outbox
207 ------
208 #<text/plain *b64
209 This is a test of a mëssäge with a shørt line.
210
211
212 This is a second line.
213
214
215
216
217 EOF
218
219 cat > "$expected" <<EOF
220 To: Mr Test <mrtest@example.com>
221 cc:
222 Fcc: +outbox
223 MIME-Version: 1.0
224 Content-Type: text/plain; charset="UTF-8"
225 Content-Transfer-Encoding: base64
226
227 VGhpcyBpcyBhIHRlc3Qgb2YgYSBtw6tzc8OkZ2Ugd2l0aCBhIHNow7hydCBsaW5lLg0KDQoNClRo
228 aXMgaXMgYSBzZWNvbmQgbGluZS4NCg0KDQoNCg0K
229 EOF
230
231 run_prog mhbuild "$draft"
232 check "$draft" "$expected"
233
234 #
235 # Test out some "long" text. By default it should end up as quoted-printable.
236 # But if we request 8bit we should error out if the line is greater than
237 # 998.
238 #
239
240 cat > "$draft" <<EOF
241 To: Mr Test <mrtest@example.com>
242 cc:
243 Fcc: +outbox
244 ------
245 This is a test of a messege with a long line. This line needs to be longer than 998 to test out the encoding rules. Will that work? That's a good question; I don't know if it will or not. I am the very model of a modern Major-General, I've information vegetable, animal, and mineral, I know the kings of England, and I quote the fights historical From Marathon to Waterloo, in order categorical, I'm very well acquainted, too, with matters mathematical, I understand equations, both the simple and quadratical, About binomial theorem I'm teeming with a lot o' news, With many cheerful facts about the square of the hypotenuse. I'm very good at integral and differential calculus; I know the scientific names of beings animalculous: In short, in matters vegetable, animal, and mineral, I am the very model of a modern Major-General. I know our mythic history, King Arthur's and Sir Caradoc's; I answer hard acrostics, I've a pretty taste for paradox, I quote in elegiacs all the crimes of Heliogabalus, In conics I can floor peculiarities parabolous; I can tell undoubted Raphaels from Gerard Dows and Zoffanies, I know the croaking chorus from The Frogs of Aristophanes! Then I can hum a fugue of which I've heard the music's din afore, And whistle all the airs from that infernal nonsense Pinafore.
246
247 This is a second line.
248 EOF
249
250 cat > "$expected" <<EOF
251 To: Mr Test <mrtest@example.com>
252 cc:
253 Fcc: +outbox
254 MIME-Version: 1.0
255 Content-Type: text/plain; charset="us-ascii"
256 Content-Transfer-Encoding: quoted-printable
257
258 This is a test of a messege with a long line. This line needs to be longe=
259 r than 998 to test out the encoding rules. Will that work? That's a good=
260 question; I don't know if it will or not. I am the very model of a moder=
261 n Major-General, I've information vegetable, animal, and mineral, I know t=
262 he kings of England, and I quote the fights historical From Marathon to Wa=
263 terloo, in order categorical, I'm very well acquainted, too, with matters =
264 mathematical, I understand equations, both the simple and quadratical, Abo=
265 ut binomial theorem I'm teeming with a lot o' news, With many cheerful fac=
266 ts about the square of the hypotenuse. I'm very good at integral and diffe=
267 rential calculus; I know the scientific names of beings animalculous: In s=
268 hort, in matters vegetable, animal, and mineral, I am the very model of a =
269 modern Major-General. I know our mythic history, King Arthur's and Sir Car=
270 adoc's; I answer hard acrostics, I've a pretty taste for paradox, I quote =
271 in elegiacs all the crimes of Heliogabalus, In conics I can floor peculiar=
272 ities parabolous; I can tell undoubted Raphaels from Gerard Dows and Zoffa=
273 nies, I know the croaking chorus from The Frogs of Aristophanes! Then I c=
274 an hum a fugue of which I've heard the music's din afore, And whistle all =
275 the airs from that infernal nonsense Pinafore. =
276
277
278 This is a second line.
279 EOF
280
281 run_prog mhbuild "$draft"
282 check "$draft" "$expected"
283
284 cat > "$draft" <<EOF
285 To: Mr Test <mrtest@example.com>
286 cc:
287 Fcc: +outbox
288 ------
289 This is a test of a messege with a long line. This line needs to be longer than 998 to test out the encoding rules. Will that work? That's a good question; I don't know if it will or not. I am the very model of a modern Major-General, I've information vegetable, animal, and mineral, I know the kings of England, and I quote the fights historical From Marathon to Waterloo, in order categorical, I'm very well acquainted, too, with matters mathematical, I understand equations, both the simple and quadratical, About binomial theorem I'm teeming with a lot o' news, With many cheerful facts about the square of the hypotenuse. I'm very good at integral and differential calculus; I know the scientific names of beings animalculous: In short, in matters vegetable, animal, and mineral, I am the very model of a modern Major-General. I know our mythic history, King Arthur's and Sir Caradoc's; I answer hard acrostics, I've a pretty taste for paradox, I quote in elegiacs all the crimes of Heliogabalus, In conics I can floor peculiarities parabolous; I can tell undoubted Raphaels from Gerard Dows and Zoffanies, I know the croaking chorus from The Frogs of Aristophanes! Then I can hum a fugue of which I've heard the music's din afore, And whistle all the airs from that infernal nonsense Pinafore.
290
291 This is a secönd line.
292 EOF
293
294 cat > "$expected" <<EOF
295 To: Mr Test <mrtest@example.com>
296 cc:
297 Fcc: +outbox
298 MIME-Version: 1.0
299 Content-Type: text/plain; charset="UTF-8"
300 Content-Transfer-Encoding: quoted-printable
301
302 This is a test of a messege with a long line. This line needs to be longe=
303 r than 998 to test out the encoding rules. Will that work? That's a good=
304 question; I don't know if it will or not. I am the very model of a moder=
305 n Major-General, I've information vegetable, animal, and mineral, I know t=
306 he kings of England, and I quote the fights historical From Marathon to Wa=
307 terloo, in order categorical, I'm very well acquainted, too, with matters =
308 mathematical, I understand equations, both the simple and quadratical, Abo=
309 ut binomial theorem I'm teeming with a lot o' news, With many cheerful fac=
310 ts about the square of the hypotenuse. I'm very good at integral and diffe=
311 rential calculus; I know the scientific names of beings animalculous: In s=
312 hort, in matters vegetable, animal, and mineral, I am the very model of a =
313 modern Major-General. I know our mythic history, King Arthur's and Sir Car=
314 adoc's; I answer hard acrostics, I've a pretty taste for paradox, I quote =
315 in elegiacs all the crimes of Heliogabalus, In conics I can floor peculiar=
316 ities parabolous; I can tell undoubted Raphaels from Gerard Dows and Zoffa=
317 nies, I know the croaking chorus from The Frogs of Aristophanes! Then I c=
318 an hum a fugue of which I've heard the music's din afore, And whistle all =
319 the airs from that infernal nonsense Pinafore. =
320
321
322 This is a sec=C3=B6nd line.
323 EOF
324
325 run_prog mhbuild "$draft"
326 check "$draft" "$expected"
327
328 cat > "$draft" <<EOF
329 To: Mr Test <mrtest@example.com>
330 cc:
331 Fcc: +outbox
332 ------
333 #<text/plain *8bit
334 This is a test of a messege with a long line. This line needs to be longer than 998 to test out the encoding rules. Will that work? That's a good question; I don't know if it will or not. I am the very model of a modern Major-General, I've information vegetable, animal, and mineral, I know the kings of England, and I quote the fights historical From Marathon to Waterloo, in order categorical, I'm very well acquainted, too, with matters mathematical, I understand equations, both the simple and quadratical, About binomial theorem I'm teeming with a lot o' news, With many cheerful facts about the square of the hypotenuse. I'm very good at integral and differential calculus; I know the scientific names of beings animalculous: In short, in matters vegetable, animal, and mineral, I am the very model of a modern Major-General. I know our mythic history, King Arthur's and Sir Caradoc's; I answer hard acrostics, I've a pretty taste for paradox, I quote in elegiacs all the crimes of Heliogabalus, In conics I can floor peculiarities parabolous; I can tell undoubted Raphaels from Gerard Dows and Zoffanies, I know the croaking chorus from The Frogs of Aristophanes! Then I can hum a fugue of which I've heard the music's din afore, And whistle all the airs from that infernal nonsense Pinafore.
335
336 This is a secönd line.
337 EOF
338
339 set +e
340 run_test 'eval mhbuild "$draft" 2>&1' 'mhbuild: Line in content exceeds maximum line limit (998)'
341 set -e
342
343 #
344 # Check to make sure -maxunencoded does what we want.
345 #
346
347 cat > "$draft" <<EOF
348 To: Mr Test <mrtest@example.com>
349 cc:
350 Fcc: +outbox
351 ------
352 This is the test of a lønger line than the usual limit. Assuming we set the maxunencded parameter properly, this should end up as 8bit?
353 EOF
354
355 cat > "$expected" <<EOF
356 To: Mr Test <mrtest@example.com>
357 cc:
358 Fcc: +outbox
359 MIME-Version: 1.0
360 Content-Type: text/plain; charset="UTF-8"
361 Content-Transfer-Encoding: 8bit
362
363 This is the test of a lønger line than the usual limit. Assuming we set the maxunencded parameter properly, this should end up as 8bit?
364 EOF
365
366 run_prog mhbuild -maxunencoded 200 "$draft"
367 check "$draft" "$expected"
368
369 [ ${failed:=0} -eq 0 ] && rm -f ${backup}
370
371 exit ${failed:-0}