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