]>
diplodocus.org Git - nmh/blob - test/mhbuild/test-utf8-body
2 ######################################################
4 # Test UTF-8 body along with an attachment
6 ######################################################
10 if test -z "${MH_OBJ_DIR}"; then
11 srcdir
=`dirname "$0"`/..
/..
12 MH_OBJ_DIR
=`cd "$srcdir" && pwd`; export MH_OBJ_DIR
15 .
"${MH_OBJ_DIR}/test/common.sh"
18 testname
="${MH_TEST_DIR}/$$"
19 expected
="$MH_TEST_DIR/$$.expected"
20 actual
="$MH_TEST_DIR/$$.actual"
22 require_locale en_US.UTF
-8 en_US.UTF8 en_US.utf
-8 en_US.utf8
24 #### Rely on sendmail/pipe below to override default mts.
25 mts_fakesendmail
="${MHMTSCONF}-fakesendmail"
26 cp "${MHMTSCONF}" "$mts_fakesendmail"
27 printf 'sendmail: %s/test/fakesendmail\n' "$srcdir" >>"$mts_fakesendmail"
28 MHMTSCONF
="$mts_fakesendmail"
30 # argument: expected output
33 run_prog send
-draft -mts sendmail
/pipe
35 # fakesendmail drops the message and any cc's into this mbox.
36 mbox
="${MH_TEST_DIR}"/Mail
/fakesendmail.mbox
37 inc
-silent -file "$mbox"
38 rm -f "$mbox" "$mbox.map"
41 # It's hard to calculate the exact Date: header post is going to
42 # use, so we'll just use sed to remove the actual date so we can easily
43 # compare it against our "correct" output. And same for charset.
45 sed -e 's/^Date:.*/Date:/' -e 's/; charset="[^;]*//' \
46 "`mhpath cur`" > "${testname}.actual"
48 check
"${testname}.actual" "$1"
52 # check that 7-bit body isn't encoded
53 start_test
"7-bit body isn't encoded"
54 cat > "${MH_TEST_DIR}/attachment.txt" <<EOF
58 cat > "${MH_TEST_DIR}/Mail/draft" <<EOF
59 From: Mr Nobody <nobody@example.com>
60 To: Somebody <somebody@example.com>
62 Attach: $MH_TEST_DIR/attachment.txt
67 cat > "${testname}.expected" <<EOF
68 From: Mr Nobody <nobody@example.com>
69 To: Somebody <somebody@example.com>
72 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
76 Content-Type: text/plain
81 Content-Type: text/plain; name="attachment.txt"
82 Content-Description: attachment.txt
83 Content-Disposition: attachment; filename="attachment.txt"
87 ------- =_aaaaaaaaaa0--
90 test_attachment
"${testname}.expected"
93 # check that 8-bit body is encoded as quoted-printable text/plain,
94 # even with an attachment
95 start_test
'8-bit body is encoded as quoted-printable text/plain'
96 cat > "${MH_TEST_DIR}/Mail/draft" <<EOF
97 From: Mr Nobody <nobody@example.com>
98 To: Somebody <somebody@example.com>
100 Attach: $MH_TEST_DIR/attachment.txt
105 cat > "${testname}.expected" <<EOF
106 From: Mr Nobody <nobody@example.com>
107 To: Somebody <somebody@example.com>
110 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
111 Content-Transfer-Encoding: 8bit
114 ------- =_aaaaaaaaaa0
115 Content-Type: text/plain
116 Content-Transfer-Encoding: 8bit
120 ------- =_aaaaaaaaaa0
121 Content-Type: text/plain; name="attachment.txt"
122 Content-Description: attachment.txt
123 Content-Disposition: attachment; filename="attachment.txt"
125 this is an attachment
127 ------- =_aaaaaaaaaa0--
130 test_attachment
"${testname}.expected"
133 # check that 8-bit attachment gets C-T-E
134 start_test
'8-bit attachment gets C-T-E'
135 rm -f "${MH_TEST_DIR}/attachment.txt"
136 cat > "${MH_TEST_DIR}/attachment.txt" <<EOF
137 8-bit attachment, ¡Ay, caramba!
140 cat > "${MH_TEST_DIR}/Mail/draft" <<EOF
141 From: Mr Nobody <nobody@example.com>
142 To: Somebody <somebody@example.com>
144 Attach: $MH_TEST_DIR/attachment.txt
147 cat > "${testname}.expected" <<EOF
148 From: Mr Nobody <nobody@example.com>
149 To: Somebody <somebody@example.com>
152 Content-Type: text/plain; name="attachment.txt"
153 Content-Description: attachment.txt
154 Content-Disposition: attachment; filename="attachment.txt"
155 Content-Transfer-Encoding: 8bit
158 8-bit attachment, ¡Ay, caramba!
161 test_attachment
"${testname}.expected"
164 # check 8-bit body but make sure that the locale is set to C, which
165 # should cause mhbuild to fail
166 start_test
'8-bit body with C locale'
167 cat > "${MH_TEST_DIR}/Mail/draft" <<EOF
168 From: Mr Nobody <nobody@example.com>
169 To: Somebody <somebody@example.com>
171 Attach: $MH_TEST_DIR/attachment.txt
176 LC_ALL
="C"; export LC_ALL
179 run_prog send
-draft -mts sendmail
/pipe
> "$actual" 2>&1
182 cat > "$expected" <<EOF
183 mhbuild: Text content contains 8 bit characters, but character set is US-ASCII
184 ${MH_INST_DIR}${bindir}/mhbuild: exit 1
187 check
"$expected" "$actual"
190 rm -f ${MHMTSCONF} "${MH_TEST_DIR}/attachment.txt"
195 # emacs hackage to ensure that it writes the inverted exclamation
196 # point as UTF-8 multibyte character \xC2\xA1 instead of just \xA1.