]> diplodocus.org Git - nmh/blob - test/mhbuild/test-utf8-body
Whoops, this should be LC_CTYPE. Fixing that exposes the lack of an
[nmh] / test / mhbuild / test-utf8-body
1 #!/bin/sh
2 ######################################################
3 #
4 # Test UTF-8 body along with an attachment
5 #
6 ######################################################
7
8 set -e
9
10 if test -z "${MH_OBJ_DIR}"; then
11 srcdir=`dirname "$0"`/../..
12 MH_OBJ_DIR=`cd "$srcdir" && pwd`; export MH_OBJ_DIR
13 fi
14
15 . "${MH_OBJ_DIR}/test/common.sh"
16
17 setup_test
18 testname="${MH_TEST_DIR}/$$"
19
20 LC_ALL=en_US.UTF-8; export LC_ALL
21
22 #### Rely on sendmail/pipe below to override default mts.
23 mts_fakesendmail="${MHMTSCONF}-fakesendmail"
24 cp "${MHMTSCONF}" "$mts_fakesendmail"
25 printf 'sendmail: %s/test/fakesendmail\n' "$srcdir" >>"$mts_fakesendmail"
26 MHMTSCONF="$mts_fakesendmail"
27
28 # argument: expected output
29 test_attachment ()
30 {
31 run_prog send -draft -mts sendmail/pipe
32
33 # fakesendmail drops the message and any cc's into this mbox.
34 mbox="${MH_TEST_DIR}"/Mail/fakesendmail.mbox
35 inc -silent -file "$mbox"
36 rm -f "$mbox" "$mbox.map"
37
38 #
39 # It's hard to calculate the exact Date: header post is going to
40 # use, so we'll just use sed to remove the actual date so we can easily
41 # compare it against our "correct" output. And same for charset.
42 #
43 sed -e 's/^Date:.*/Date:/' -e 's/; charset="[^;]*//' \
44 "`mhpath cur`" > "${testname}.actual"
45
46 check "${testname}.actual" "$1"
47 }
48
49 # check that 7-bit body isn't encoded
50 cat > "${MH_TEST_DIR}/attachment.txt" <<EOF
51 this is an attachment
52 EOF
53
54 cat > "${MH_TEST_DIR}/Mail/draft" <<EOF
55 From: Mr Nobody <nobody@example.com>
56 To: Somebody <somebody@example.com>
57 Subject: Test
58 Attach: $MH_TEST_DIR/attachment.txt
59
60 This is a test.
61 EOF
62
63 cat > "${testname}.expected" <<EOF
64 From: Mr Nobody <nobody@example.com>
65 To: Somebody <somebody@example.com>
66 Subject: Test
67 MIME-Version: 1.0
68 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
69 Date:
70
71 ------- =_aaaaaaaaaa0
72 Content-Type: text/plain
73
74 This is a test.
75
76 ------- =_aaaaaaaaaa0
77 Content-Type: text/plain; name="attachment.txt"
78 Content-Description: attachment.txt
79 Content-Disposition: attachment; filename="attachment.txt"
80
81 this is an attachment
82
83 ------- =_aaaaaaaaaa0--
84 EOF
85
86 test_attachment "${testname}.expected"
87
88 # check that 8-bit body is encoded as quoted-printable text/plain,
89 # even with an attachment
90
91 cat > "${MH_TEST_DIR}/Mail/draft" <<EOF
92 From: Mr Nobody <nobody@example.com>
93 To: Somebody <somebody@example.com>
94 Subject: Test
95 Attach: $MH_TEST_DIR/attachment.txt
96
97 ¡Ay, caramba!
98 EOF
99
100 cat > "${testname}.expected" <<EOF
101 From: Mr Nobody <nobody@example.com>
102 To: Somebody <somebody@example.com>
103 Subject: Test
104 MIME-Version: 1.0
105 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
106 Content-Transfer-Encoding: 8bit
107 Date:
108
109 ------- =_aaaaaaaaaa0
110 Content-Type: text/plain
111 Content-Transfer-Encoding: 8bit
112
113 ¡Ay, caramba!
114
115 ------- =_aaaaaaaaaa0
116 Content-Type: text/plain; name="attachment.txt"
117 Content-Description: attachment.txt
118 Content-Disposition: attachment; filename="attachment.txt"
119
120 this is an attachment
121
122 ------- =_aaaaaaaaaa0--
123 EOF
124
125 test_attachment "${testname}.expected"
126
127 rm -f ${MHMTSCONF} "${MH_TEST_DIR}/attachment.txt"
128
129 exit ${failed:-0}
130
131 # emacs hackage to ensure that it writes the inverted exclamation
132 # point as UTF-8 multibyte character \xC2\xA1 instead of just \xA1.
133 # Local Variables:
134 # coding: utf-8
135 # End: