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.
52 # Force some text to be base64, to test out the encoder. Try at different
53 # line lengths to check out the padding on the routines to convert LF to
54 # CR LF. The current implementation reads in using a 3 byte buffer, so make
55 # sure we catch all of those cases.
59 To: Mr Test <mrtest@example.com>
64 This is a test of a message with a shørt line.
67 run_prog mhbuild
"$draft"
69 cat > "$expected" <<EOF
70 To: Mr Test <mrtest@example.com>
74 Content-Type: text/plain; charset="UTF-8"
75 Content-Transfer-Encoding: base64
77 VGhpcyBpcyBhIHRlc3Qgb2YgYSBtZXNzYWdlIHdpdGggYSBzaMO4cnQgbGluZS4NCg==
80 check
"$draft" "$expected"
83 To: Mr Test <mrtest@example.com>
88 This is a test of a mëssage with a shørt line.
91 run_prog mhbuild
"$draft"
93 cat > "$expected" <<EOF
94 To: Mr Test <mrtest@example.com>
98 Content-Type: text/plain; charset="UTF-8"
99 Content-Transfer-Encoding: base64
101 VGhpcyBpcyBhIHRlc3Qgb2YgYSBtw6tzc2FnZSB3aXRoIGEgc2jDuHJ0IGxpbmUuDQo=
104 check
"$draft" "$expected"
107 To: Mr Test <mrtest@example.com>
112 This is a test of a mëssäge with a shørt line.
115 run_prog mhbuild
"$draft"
117 cat > "$expected" <<EOF
118 To: Mr Test <mrtest@example.com>
122 Content-Type: text/plain; charset="UTF-8"
123 Content-Transfer-Encoding: base64
125 VGhpcyBpcyBhIHRlc3Qgb2YgYSBtw6tzc8OkZ2Ugd2l0aCBhIHNow7hydCBsaW5lLg0K
128 check
"$draft" "$expected"
131 To: Mr Test <mrtest@example.com>
136 This is a test of a message with a shørt line.
137 This is a second line.
140 run_prog mhbuild
"$draft"
142 cat > "$expected" <<EOF
143 To: Mr Test <mrtest@example.com>
147 Content-Type: text/plain; charset="UTF-8"
148 Content-Transfer-Encoding: base64
150 VGhpcyBpcyBhIHRlc3Qgb2YgYSBtZXNzYWdlIHdpdGggYSBzaMO4cnQgbGluZS4NClRoaXMgaXMg
151 YSBzZWNvbmQgbGluZS4NCg==
154 check
"$draft" "$expected"
157 To: Mr Test <mrtest@example.com>
162 This is a test of a mëssage with a shørt line.
163 This is a second line.
166 run_prog mhbuild
"$draft"
168 cat > "$expected" <<EOF
169 To: Mr Test <mrtest@example.com>
173 Content-Type: text/plain; charset="UTF-8"
174 Content-Transfer-Encoding: base64
176 VGhpcyBpcyBhIHRlc3Qgb2YgYSBtw6tzc2FnZSB3aXRoIGEgc2jDuHJ0IGxpbmUuDQpUaGlzIGlz
177 IGEgc2Vjb25kIGxpbmUuDQo=
180 check
"$draft" "$expected"
183 To: Mr Test <mrtest@example.com>
188 This is a test of a mëssäge with a shørt line.
189 This is a second line.
192 run_prog mhbuild
"$draft"
194 cat > "$expected" <<EOF
195 To: Mr Test <mrtest@example.com>
199 Content-Type: text/plain; charset="UTF-8"
200 Content-Transfer-Encoding: base64
202 VGhpcyBpcyBhIHRlc3Qgb2YgYSBtw6tzc8OkZ2Ugd2l0aCBhIHNow7hydCBsaW5lLg0KVGhpcyBp
203 cyBhIHNlY29uZCBsaW5lLg0K
206 check
"$draft" "$expected"
209 To: Mr Test <mrtest@example.com>
214 This is a test of a mëssäge with a shørt line.
217 This is a second line.
224 run_prog mhbuild
"$draft"
226 cat > "$expected" <<EOF
227 To: Mr Test <mrtest@example.com>
231 Content-Type: text/plain; charset="UTF-8"
232 Content-Transfer-Encoding: base64
234 VGhpcyBpcyBhIHRlc3Qgb2YgYSBtw6tzc8OkZ2Ugd2l0aCBhIHNow7hydCBsaW5lLg0KDQoNClRo
235 aXMgaXMgYSBzZWNvbmQgbGluZS4NCg0KDQoNCg0K
238 check
"$draft" "$expected"
241 # Test out some "long" text. By default it should end up as quoted-printable.
242 # But if we request 8bit we should error out if the line is greater than
247 To: Mr Test <mrtest@example.com>
251 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 This is a second line.
256 run_prog mhbuild
"$draft"
258 cat > "$expected" <<EOF
259 To: Mr Test <mrtest@example.com>
263 Content-Type: text/plain; charset="us-ascii"
264 Content-Transfer-Encoding: quoted-printable
266 This is a test of a messege with a long line. This line needs to be longe=
267 r than 998 to test out the encoding rules. Will that work? That's a good=
268 question; I don't know if it will or not. I am the very model of a moder=
269 n Major-General, I've information vegetable, animal, and mineral, I know t=
270 he kings of England, and I quote the fights historical From Marathon to Wa=
271 terloo, in order categorical, I'm very well acquainted, too, with matters =
272 mathematical, I understand equations, both the simple and quadratical, Abo=
273 ut binomial theorem I'm teeming with a lot o' news, With many cheerful fac=
274 ts about the square of the hypotenuse. I'm very good at integral and diffe=
275 rential calculus; I know the scientific names of beings animalculous: In s=
276 hort, in matters vegetable, animal, and mineral, I am the very model of a =
277 modern Major-General. I know our mythic history, King Arthur's and Sir Car=
278 adoc's; I answer hard acrostics, I've a pretty taste for paradox, I quote =
279 in elegiacs all the crimes of Heliogabalus, In conics I can floor peculiar=
280 ities parabolous; I can tell undoubted Raphaels from Gerard Dows and Zoffa=
281 nies, I know the croaking chorus from The Frogs of Aristophanes! Then I c=
282 an hum a fugue of which I've heard the music's din afore, And whistle all =
283 the airs from that infernal nonsense Pinafore. =
286 This is a second line.
289 check
"$draft" "$expected"
292 To: Mr Test <mrtest@example.com>
296 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 This is a secönd line.
301 run_prog mhbuild
"$draft"
303 cat > "$expected" <<EOF
304 To: Mr Test <mrtest@example.com>
308 Content-Type: text/plain; charset="UTF-8"
309 Content-Transfer-Encoding: quoted-printable
311 This is a test of a messege with a long line. This line needs to be longe=
312 r than 998 to test out the encoding rules. Will that work? That's a good=
313 question; I don't know if it will or not. I am the very model of a moder=
314 n Major-General, I've information vegetable, animal, and mineral, I know t=
315 he kings of England, and I quote the fights historical From Marathon to Wa=
316 terloo, in order categorical, I'm very well acquainted, too, with matters =
317 mathematical, I understand equations, both the simple and quadratical, Abo=
318 ut binomial theorem I'm teeming with a lot o' news, With many cheerful fac=
319 ts about the square of the hypotenuse. I'm very good at integral and diffe=
320 rential calculus; I know the scientific names of beings animalculous: In s=
321 hort, in matters vegetable, animal, and mineral, I am the very model of a =
322 modern Major-General. I know our mythic history, King Arthur's and Sir Car=
323 adoc's; I answer hard acrostics, I've a pretty taste for paradox, I quote =
324 in elegiacs all the crimes of Heliogabalus, In conics I can floor peculiar=
325 ities parabolous; I can tell undoubted Raphaels from Gerard Dows and Zoffa=
326 nies, I know the croaking chorus from The Frogs of Aristophanes! Then I c=
327 an hum a fugue of which I've heard the music's din afore, And whistle all =
328 the airs from that infernal nonsense Pinafore. =
331 This is a sec=C3=B6nd line.
334 check
"$draft" "$expected"
337 To: Mr Test <mrtest@example.com>
342 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 This is a secönd line.
348 run_test
'eval mhbuild "$draft" 2>&1' 'mhbuild: Line in content exceeds maximum line limit (998)'
352 # Check to make sure -maxunencoded does what we want.
356 To: Mr Test <mrtest@example.com>
360 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?
363 run_prog mhbuild
-maxunencoded 200 "$draft"
365 cat > "$expected" <<EOF
366 To: Mr Test <mrtest@example.com>
370 Content-Type: text/plain; charset="UTF-8"
371 Content-Transfer-Encoding: 8bit
373 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?
376 check
"$draft" "$expected"
378 [ ${failed:=0} -eq 0 ] && rm -f ${backup}