File: test-cte

package info (click to toggle)
nmh 1.6-2
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 6,204 kB
  • ctags: 3,851
  • sloc: ansic: 48,922; sh: 16,422; makefile: 559; perl: 509; lex: 402; awk: 74
file content (383 lines) | stat: -rwxr-xr-x 13,200 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
#!/bin/sh
#########################################################
#
# Test the use of explicit Content-Transfer-Encoding tags
#
#########################################################

if test -z "${MH_OBJ_DIR}"; then
    srcdir=`dirname "$0"`/../..
    MH_OBJ_DIR=`cd "$srcdir" && pwd`; export MH_OBJ_DIR
fi

. "$MH_OBJ_DIR/test/common.sh"

setup_test

set -e

if ! locale -a | grep -iq en_us.utf; then
    test_skip "no suitable locale available"
fi
LC_ALL=en_US.UTF-8; export LC_ALL

draft="$MH_TEST_DIR/$$.draft"
backup="${MH_TEST_DIR}/`mhparam sbackup`$$.draft.orig"
expected="$MH_TEST_DIR/$$.expected"

#
# Force some text to be quoted-printable
#

cat > "$draft" <<EOF
To: Mr Test <mrtest@example.com>
cc:
Fcc: +outbox
------
#<text/plain *qp
This is a test of a message with a shørt line.
EOF

run_prog mhbuild "$draft"

cat > "$expected" <<EOF
To: Mr Test <mrtest@example.com>
cc:
Fcc: +outbox
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

This is a test of a message with a sh=C3=B8rt line.
EOF

#
# Force some text to be base64, to test out the encoder.  Try at different
# line lengths to check out the padding on the routines to convert LF to
# CR LF.  The current implementation reads in using a 3 byte buffer, so make
# sure we catch all of those cases.
#

cat > "$draft" <<EOF
To: Mr Test <mrtest@example.com>
cc:
Fcc: +outbox
------
#<text/plain *b64
This is a test of a message with a shørt line.
EOF

run_prog mhbuild "$draft"

cat > "$expected" <<EOF
To: Mr Test <mrtest@example.com>
cc:
Fcc: +outbox
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: base64

VGhpcyBpcyBhIHRlc3Qgb2YgYSBtZXNzYWdlIHdpdGggYSBzaMO4cnQgbGluZS4NCg==
EOF

check "$draft" "$expected"

cat > "$draft" <<EOF
To: Mr Test <mrtest@example.com>
cc:
Fcc: +outbox
------
#<text/plain *b64
This is a test of a mëssage with a shørt line.
EOF

run_prog mhbuild "$draft"

cat > "$expected" <<EOF
To: Mr Test <mrtest@example.com>
cc:
Fcc: +outbox
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: base64

VGhpcyBpcyBhIHRlc3Qgb2YgYSBtw6tzc2FnZSB3aXRoIGEgc2jDuHJ0IGxpbmUuDQo=
EOF

check "$draft" "$expected"

cat > "$draft" <<EOF
To: Mr Test <mrtest@example.com>
cc:
Fcc: +outbox
------
#<text/plain *b64
This is a test of a mëssäge with a shørt line.
EOF

run_prog mhbuild "$draft"

cat > "$expected" <<EOF
To: Mr Test <mrtest@example.com>
cc:
Fcc: +outbox
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: base64

VGhpcyBpcyBhIHRlc3Qgb2YgYSBtw6tzc8OkZ2Ugd2l0aCBhIHNow7hydCBsaW5lLg0K
EOF

check "$draft" "$expected"

cat > "$draft" <<EOF
To: Mr Test <mrtest@example.com>
cc:
Fcc: +outbox
------
#<text/plain *b64
This is a test of a message with a shørt line.
This is a second line.
EOF

run_prog mhbuild "$draft"

cat > "$expected" <<EOF
To: Mr Test <mrtest@example.com>
cc:
Fcc: +outbox
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: base64

VGhpcyBpcyBhIHRlc3Qgb2YgYSBtZXNzYWdlIHdpdGggYSBzaMO4cnQgbGluZS4NClRoaXMgaXMg
YSBzZWNvbmQgbGluZS4NCg==
EOF

check "$draft" "$expected"

cat > "$draft" <<EOF
To: Mr Test <mrtest@example.com>
cc:
Fcc: +outbox
------
#<text/plain *b64
This is a test of a mëssage with a shørt line.
This is a second line.
EOF

run_prog mhbuild "$draft"

cat > "$expected" <<EOF
To: Mr Test <mrtest@example.com>
cc:
Fcc: +outbox
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: base64

VGhpcyBpcyBhIHRlc3Qgb2YgYSBtw6tzc2FnZSB3aXRoIGEgc2jDuHJ0IGxpbmUuDQpUaGlzIGlz
IGEgc2Vjb25kIGxpbmUuDQo=
EOF

check "$draft" "$expected"

cat > "$draft" <<EOF
To: Mr Test <mrtest@example.com>
cc:
Fcc: +outbox
------
#<text/plain *b64
This is a test of a mëssäge with a shørt line.
This is a second line.
EOF

run_prog mhbuild "$draft"

cat > "$expected" <<EOF
To: Mr Test <mrtest@example.com>
cc:
Fcc: +outbox
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: base64

VGhpcyBpcyBhIHRlc3Qgb2YgYSBtw6tzc8OkZ2Ugd2l0aCBhIHNow7hydCBsaW5lLg0KVGhpcyBp
cyBhIHNlY29uZCBsaW5lLg0K
EOF

check "$draft" "$expected"

cat > "$draft" <<EOF
To: Mr Test <mrtest@example.com>
cc:
Fcc: +outbox
------
#<text/plain *b64
This is a test of a mëssäge with a shørt line.


This is a second line.




EOF

run_prog mhbuild "$draft"

cat > "$expected" <<EOF
To: Mr Test <mrtest@example.com>
cc:
Fcc: +outbox
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: base64

VGhpcyBpcyBhIHRlc3Qgb2YgYSBtw6tzc8OkZ2Ugd2l0aCBhIHNow7hydCBsaW5lLg0KDQoNClRo
aXMgaXMgYSBzZWNvbmQgbGluZS4NCg0KDQoNCg0K
EOF

check "$draft" "$expected"

#
# Test out some "long" text.  By default it should end up as quoted-printable.
# But if we request 8bit we should error out if the line is greater than
# 998.
#

cat > "$draft" <<EOF
To: Mr Test <mrtest@example.com>
cc:
Fcc: +outbox
------
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. 

This is a second line.
EOF

run_prog mhbuild "$draft"

cat > "$expected" <<EOF
To: Mr Test <mrtest@example.com>
cc:
Fcc: +outbox
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

This is a test of a messege with a long line.  This line needs to be longe=
r 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 moder=
n Major-General, I've information vegetable, animal, and mineral, I know t=
he kings of England, and I quote the fights historical From Marathon to Wa=
terloo, in order categorical, I'm very well acquainted, too, with matters =
mathematical, I understand equations, both the simple and quadratical, Abo=
ut binomial theorem I'm teeming with a lot o' news, With many cheerful fac=
ts about the square of the hypotenuse. I'm very good at integral and diffe=
rential calculus; I know the scientific names of beings animalculous: In s=
hort, 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 Car=
adoc'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 peculiar=
ities parabolous; I can tell undoubted Raphaels from Gerard Dows and Zoffa=
nies, I know the croaking chorus from The Frogs of Aristophanes!  Then I c=
an hum a fugue of which I've heard the music's din afore, And whistle all =
the airs from that infernal nonsense Pinafore. =


This is a second line.
EOF

check "$draft" "$expected"

cat > "$draft" <<EOF
To: Mr Test <mrtest@example.com>
cc:
Fcc: +outbox
------
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. 

This is a secönd line.
EOF

run_prog mhbuild "$draft"

cat > "$expected" <<EOF
To: Mr Test <mrtest@example.com>
cc:
Fcc: +outbox
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

This is a test of a messege with a long line.  This line needs to be longe=
r 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 moder=
n Major-General, I've information vegetable, animal, and mineral, I know t=
he kings of England, and I quote the fights historical From Marathon to Wa=
terloo, in order categorical, I'm very well acquainted, too, with matters =
mathematical, I understand equations, both the simple and quadratical, Abo=
ut binomial theorem I'm teeming with a lot o' news, With many cheerful fac=
ts about the square of the hypotenuse. I'm very good at integral and diffe=
rential calculus; I know the scientific names of beings animalculous: In s=
hort, 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 Car=
adoc'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 peculiar=
ities parabolous; I can tell undoubted Raphaels from Gerard Dows and Zoffa=
nies, I know the croaking chorus from The Frogs of Aristophanes!  Then I c=
an hum a fugue of which I've heard the music's din afore, And whistle all =
the airs from that infernal nonsense Pinafore. =


This is a sec=C3=B6nd line.
EOF

check "$draft" "$expected"

cat > "$draft" <<EOF
To: Mr Test <mrtest@example.com>
cc:
Fcc: +outbox
------
#<text/plain *8bit
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. 

This is a secönd line.
EOF

set +e
run_test 'eval mhbuild "$draft" 2>&1' 'mhbuild: Line in content exceeds maximum line limit (998)'
set -e

#
# Check to make sure -maxunencoded does what we want.
#

cat > "$draft" <<EOF
To: Mr Test <mrtest@example.com>
cc:
Fcc: +outbox
------
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?
EOF

run_prog mhbuild -maxunencoded 200 "$draft"

cat > "$expected" <<EOF
To: Mr Test <mrtest@example.com>
cc:
Fcc: +outbox
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 8bit

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?
EOF

check "$draft" "$expected"

[ ${failed:=0} -eq 0 ]  &&  rm -f ${backup}

exit ${failed:-0}