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