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