2 #########################################################
4 # Test the use of explicit Content-Transfer-Encoding tags
6 #########################################################
8 if test -z "${MH_OBJ_DIR}"; then
9 srcdir
=`dirname "$0"`/..
/..
10 MH_OBJ_DIR
=`cd "$srcdir" && pwd`; export MH_OBJ_DIR
13 .
"$MH_OBJ_DIR/test/common.sh"
19 require_locale en_US.utf-8 en_US.utf8
20 LC_ALL
=en_US.UTF-8
; export LC_ALL
22 draft
="$MH_TEST_DIR/$$.draft"
23 backup
="${MH_TEST_DIR}/`mhparam sbackup`$$.draft.orig"
24 expected
="$MH_TEST_DIR/$$.expected"
27 # Force some text to be quoted-printable
31 To: Mr Test <mrtest@example.com>
36 This is a test of a message with a shørt line.
39 run_prog mhbuild
"$draft"
41 cat > "$expected" <<EOF
42 To: Mr Test <mrtest@example.com>
46 Content-Type: text/plain; charset="UTF-8"
47 Content-Transfer-Encoding: quoted-printable
49 This is a test of a message with a sh=C3=B8rt line.
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.
60 To: Mr Test <mrtest@example.com>
65 This is a test of a message with a shørt line.
68 run_prog mhbuild
"$draft"
70 cat > "$expected" <<EOF
71 To: Mr Test <mrtest@example.com>
75 Content-Type: text/plain; charset="UTF-8"
76 Content-Transfer-Encoding: base64
78 VGhpcyBpcyBhIHRlc3Qgb2YgYSBtZXNzYWdlIHdpdGggYSBzaMO4cnQgbGluZS4NCg==
81 check
"$draft" "$expected"
84 To: Mr Test <mrtest@example.com>
89 This is a test of a mëssage with a shørt line.
92 run_prog mhbuild
"$draft"
94 cat > "$expected" <<EOF
95 To: Mr Test <mrtest@example.com>
99 Content-Type: text/plain; charset="UTF-8"
100 Content-Transfer-Encoding: base64
102 VGhpcyBpcyBhIHRlc3Qgb2YgYSBtw6tzc2FnZSB3aXRoIGEgc2jDuHJ0IGxpbmUuDQo=
105 check
"$draft" "$expected"
108 To: Mr Test <mrtest@example.com>
113 This is a test of a mëssäge with a shørt line.
116 run_prog mhbuild
"$draft"
118 cat > "$expected" <<EOF
119 To: Mr Test <mrtest@example.com>
123 Content-Type: text/plain; charset="UTF-8"
124 Content-Transfer-Encoding: base64
126 VGhpcyBpcyBhIHRlc3Qgb2YgYSBtw6tzc8OkZ2Ugd2l0aCBhIHNow7hydCBsaW5lLg0K
129 check
"$draft" "$expected"
132 To: Mr Test <mrtest@example.com>
137 This is a test of a message with a shørt line.
138 This is a second line.
141 run_prog mhbuild
"$draft"
143 cat > "$expected" <<EOF
144 To: Mr Test <mrtest@example.com>
148 Content-Type: text/plain; charset="UTF-8"
149 Content-Transfer-Encoding: base64
151 VGhpcyBpcyBhIHRlc3Qgb2YgYSBtZXNzYWdlIHdpdGggYSBzaMO4cnQgbGluZS4NClRoaXMgaXMg
152 YSBzZWNvbmQgbGluZS4NCg==
155 check
"$draft" "$expected"
158 To: Mr Test <mrtest@example.com>
163 This is a test of a mëssage with a shørt line.
164 This is a second line.
167 run_prog mhbuild
"$draft"
169 cat > "$expected" <<EOF
170 To: Mr Test <mrtest@example.com>
174 Content-Type: text/plain; charset="UTF-8"
175 Content-Transfer-Encoding: base64
177 VGhpcyBpcyBhIHRlc3Qgb2YgYSBtw6tzc2FnZSB3aXRoIGEgc2jDuHJ0IGxpbmUuDQpUaGlzIGlz
178 IGEgc2Vjb25kIGxpbmUuDQo=
181 check
"$draft" "$expected"
184 To: Mr Test <mrtest@example.com>
189 This is a test of a mëssäge with a shørt line.
190 This is a second line.
193 run_prog mhbuild
"$draft"
195 cat > "$expected" <<EOF
196 To: Mr Test <mrtest@example.com>
200 Content-Type: text/plain; charset="UTF-8"
201 Content-Transfer-Encoding: base64
203 VGhpcyBpcyBhIHRlc3Qgb2YgYSBtw6tzc8OkZ2Ugd2l0aCBhIHNow7hydCBsaW5lLg0KVGhpcyBp
204 cyBhIHNlY29uZCBsaW5lLg0K
207 check
"$draft" "$expected"
210 To: Mr Test <mrtest@example.com>
215 This is a test of a mëssäge with a shørt line.
218 This is a second line.
225 run_prog mhbuild
"$draft"
227 cat > "$expected" <<EOF
228 To: Mr Test <mrtest@example.com>
232 Content-Type: text/plain; charset="UTF-8"
233 Content-Transfer-Encoding: base64
235 VGhpcyBpcyBhIHRlc3Qgb2YgYSBtw6tzc8OkZ2Ugd2l0aCBhIHNow7hydCBsaW5lLg0KDQoNClRo
236 aXMgaXMgYSBzZWNvbmQgbGluZS4NCg0KDQoNCg0K
239 check
"$draft" "$expected"
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
248 To: Mr Test <mrtest@example.com>
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.
254 This is a second line.
257 run_prog mhbuild
"$draft"
259 cat > "$expected" <<EOF
260 To: Mr Test <mrtest@example.com>
264 Content-Type: text/plain; charset="us-ascii"
265 Content-Transfer-Encoding: quoted-printable
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. =
287 This is a second line.
290 check
"$draft" "$expected"
293 To: Mr Test <mrtest@example.com>
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.
299 This is a secönd line.
302 run_prog mhbuild
"$draft"
304 cat > "$expected" <<EOF
305 To: Mr Test <mrtest@example.com>
309 Content-Type: text/plain; charset="UTF-8"
310 Content-Transfer-Encoding: quoted-printable
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. =
332 This is a sec=C3=B6nd line.
335 check
"$draft" "$expected"
338 To: Mr Test <mrtest@example.com>
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.
345 This is a secönd line.
349 run_test
'eval mhbuild "$draft" 2>&1' 'mhbuild: Line in content exceeds maximum line limit (998)'
353 # Check to make sure -maxunencoded does what we want.
357 To: Mr Test <mrtest@example.com>
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?
364 run_prog mhbuild
-maxunencoded 200 "$draft"
366 cat > "$expected" <<EOF
367 To: Mr Test <mrtest@example.com>
371 Content-Type: text/plain; charset="UTF-8"
372 Content-Transfer-Encoding: 8bit
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?
377 check
"$draft" "$expected"
379 [ ${failed:=0} -eq 0 ] && rm -f ${backup}