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 en_US.utf-8 en_US.utf8
21 draft
="$MH_TEST_DIR/$$.draft"
22 backup
="${MH_TEST_DIR}/`mhparam sbackup`$$.draft.orig"
23 expected
="$MH_TEST_DIR/$$.expected"
26 # Force some text to be quoted-printable
30 To: Mr Test <mrtest@example.com>
35 This is a test of a message with a shørt line.
38 run_prog mhbuild
"$draft"
40 cat > "$expected" <<EOF
41 To: Mr Test <mrtest@example.com>
45 Content-Type: text/plain; charset="UTF-8"
46 Content-Transfer-Encoding: quoted-printable
48 This is a test of a message with a sh=C3=B8rt line.
51 check
"$draft" "$expected"
54 # Force some text to be base64, to test out the encoder. Try at different
55 # line lengths to check out the padding on the routines to convert LF to
56 # CR LF. The current implementation reads in using a 3 byte buffer, so make
57 # sure we catch all of those cases.
61 To: Mr Test <mrtest@example.com>
66 This is a test of a message with a shørt line.
69 run_prog mhbuild
"$draft"
71 cat > "$expected" <<EOF
72 To: Mr Test <mrtest@example.com>
76 Content-Type: text/plain; charset="UTF-8"
77 Content-Transfer-Encoding: base64
79 VGhpcyBpcyBhIHRlc3Qgb2YgYSBtZXNzYWdlIHdpdGggYSBzaMO4cnQgbGluZS4NCg==
82 check
"$draft" "$expected"
85 To: Mr Test <mrtest@example.com>
90 This is a test of a mëssage with a shørt line.
93 run_prog mhbuild
"$draft"
95 cat > "$expected" <<EOF
96 To: Mr Test <mrtest@example.com>
100 Content-Type: text/plain; charset="UTF-8"
101 Content-Transfer-Encoding: base64
103 VGhpcyBpcyBhIHRlc3Qgb2YgYSBtw6tzc2FnZSB3aXRoIGEgc2jDuHJ0IGxpbmUuDQo=
106 check
"$draft" "$expected"
109 To: Mr Test <mrtest@example.com>
114 This is a test of a mëssäge with a shørt line.
117 run_prog mhbuild
"$draft"
119 cat > "$expected" <<EOF
120 To: Mr Test <mrtest@example.com>
124 Content-Type: text/plain; charset="UTF-8"
125 Content-Transfer-Encoding: base64
127 VGhpcyBpcyBhIHRlc3Qgb2YgYSBtw6tzc8OkZ2Ugd2l0aCBhIHNow7hydCBsaW5lLg0K
130 check
"$draft" "$expected"
133 To: Mr Test <mrtest@example.com>
138 This is a test of a message with a shørt line.
139 This is a second line.
142 run_prog mhbuild
"$draft"
144 cat > "$expected" <<EOF
145 To: Mr Test <mrtest@example.com>
149 Content-Type: text/plain; charset="UTF-8"
150 Content-Transfer-Encoding: base64
152 VGhpcyBpcyBhIHRlc3Qgb2YgYSBtZXNzYWdlIHdpdGggYSBzaMO4cnQgbGluZS4NClRoaXMgaXMg
153 YSBzZWNvbmQgbGluZS4NCg==
156 check
"$draft" "$expected"
159 To: Mr Test <mrtest@example.com>
164 This is a test of a mëssage with a shørt line.
165 This is a second line.
168 run_prog mhbuild
"$draft"
170 cat > "$expected" <<EOF
171 To: Mr Test <mrtest@example.com>
175 Content-Type: text/plain; charset="UTF-8"
176 Content-Transfer-Encoding: base64
178 VGhpcyBpcyBhIHRlc3Qgb2YgYSBtw6tzc2FnZSB3aXRoIGEgc2jDuHJ0IGxpbmUuDQpUaGlzIGlz
179 IGEgc2Vjb25kIGxpbmUuDQo=
182 check
"$draft" "$expected"
185 To: Mr Test <mrtest@example.com>
190 This is a test of a mëssäge with a shørt line.
191 This is a second line.
194 run_prog mhbuild
"$draft"
196 cat > "$expected" <<EOF
197 To: Mr Test <mrtest@example.com>
201 Content-Type: text/plain; charset="UTF-8"
202 Content-Transfer-Encoding: base64
204 VGhpcyBpcyBhIHRlc3Qgb2YgYSBtw6tzc8OkZ2Ugd2l0aCBhIHNow7hydCBsaW5lLg0KVGhpcyBp
205 cyBhIHNlY29uZCBsaW5lLg0K
208 check
"$draft" "$expected"
211 To: Mr Test <mrtest@example.com>
216 This is a test of a mëssäge with a shørt line.
219 This is a second line.
226 run_prog mhbuild
"$draft"
228 cat > "$expected" <<EOF
229 To: Mr Test <mrtest@example.com>
233 Content-Type: text/plain; charset="UTF-8"
234 Content-Transfer-Encoding: base64
236 VGhpcyBpcyBhIHRlc3Qgb2YgYSBtw6tzc8OkZ2Ugd2l0aCBhIHNow7hydCBsaW5lLg0KDQoNClRo
237 aXMgaXMgYSBzZWNvbmQgbGluZS4NCg0KDQoNCg0K
240 check
"$draft" "$expected"
243 # Test out some "long" text. By default it should end up as quoted-printable.
244 # But if we request 8bit we should error out if the line is greater than
249 To: Mr Test <mrtest@example.com>
253 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.
255 This is a second line.
258 run_prog mhbuild
"$draft"
260 cat > "$expected" <<EOF
261 To: Mr Test <mrtest@example.com>
265 Content-Type: text/plain; charset="us-ascii"
266 Content-Transfer-Encoding: quoted-printable
268 This is a test of a messege with a long line. This line needs to be longe=
269 r than 998 to test out the encoding rules. Will that work? That's a good=
270 question; I don't know if it will or not. I am the very model of a moder=
271 n Major-General, I've information vegetable, animal, and mineral, I know t=
272 he kings of England, and I quote the fights historical From Marathon to Wa=
273 terloo, in order categorical, I'm very well acquainted, too, with matters =
274 mathematical, I understand equations, both the simple and quadratical, Abo=
275 ut binomial theorem I'm teeming with a lot o' news, With many cheerful fac=
276 ts about the square of the hypotenuse. I'm very good at integral and diffe=
277 rential calculus; I know the scientific names of beings animalculous: In s=
278 hort, in matters vegetable, animal, and mineral, I am the very model of a =
279 modern Major-General. I know our mythic history, King Arthur's and Sir Car=
280 adoc's; I answer hard acrostics, I've a pretty taste for paradox, I quote =
281 in elegiacs all the crimes of Heliogabalus, In conics I can floor peculiar=
282 ities parabolous; I can tell undoubted Raphaels from Gerard Dows and Zoffa=
283 nies, I know the croaking chorus from The Frogs of Aristophanes! Then I c=
284 an hum a fugue of which I've heard the music's din afore, And whistle all =
285 the airs from that infernal nonsense Pinafore. =
288 This is a second line.
291 check
"$draft" "$expected"
294 To: Mr Test <mrtest@example.com>
298 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.
300 This is a secönd line.
303 run_prog mhbuild
"$draft"
305 cat > "$expected" <<EOF
306 To: Mr Test <mrtest@example.com>
310 Content-Type: text/plain; charset="UTF-8"
311 Content-Transfer-Encoding: quoted-printable
313 This is a test of a messege with a long line. This line needs to be longe=
314 r than 998 to test out the encoding rules. Will that work? That's a good=
315 question; I don't know if it will or not. I am the very model of a moder=
316 n Major-General, I've information vegetable, animal, and mineral, I know t=
317 he kings of England, and I quote the fights historical From Marathon to Wa=
318 terloo, in order categorical, I'm very well acquainted, too, with matters =
319 mathematical, I understand equations, both the simple and quadratical, Abo=
320 ut binomial theorem I'm teeming with a lot o' news, With many cheerful fac=
321 ts about the square of the hypotenuse. I'm very good at integral and diffe=
322 rential calculus; I know the scientific names of beings animalculous: In s=
323 hort, in matters vegetable, animal, and mineral, I am the very model of a =
324 modern Major-General. I know our mythic history, King Arthur's and Sir Car=
325 adoc's; I answer hard acrostics, I've a pretty taste for paradox, I quote =
326 in elegiacs all the crimes of Heliogabalus, In conics I can floor peculiar=
327 ities parabolous; I can tell undoubted Raphaels from Gerard Dows and Zoffa=
328 nies, I know the croaking chorus from The Frogs of Aristophanes! Then I c=
329 an hum a fugue of which I've heard the music's din afore, And whistle all =
330 the airs from that infernal nonsense Pinafore. =
333 This is a sec=C3=B6nd line.
336 check
"$draft" "$expected"
339 To: Mr Test <mrtest@example.com>
344 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.
346 This is a secönd line.
350 run_test
'eval mhbuild "$draft" 2>&1' 'mhbuild: Line in content exceeds maximum line limit (998)'
354 # Check to make sure -maxunencoded does what we want.
358 To: Mr Test <mrtest@example.com>
362 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?
365 run_prog mhbuild
-maxunencoded 200 "$draft"
367 cat > "$expected" <<EOF
368 To: Mr Test <mrtest@example.com>
372 Content-Type: text/plain; charset="UTF-8"
373 Content-Transfer-Encoding: 8bit
375 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?
378 check
"$draft" "$expected"
380 [ ${failed:=0} -eq 0 ] && rm -f ${backup}