]>
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
23 LC_ALL
=en_US.UTF
-8; export LC_ALL
25 #### Rely on sendmail/pipe below to override default mts.
26 mts_fakesendmail
="${MHMTSCONF}-fakesendmail"
27 cp "${MHMTSCONF}" "$mts_fakesendmail"
28 printf 'sendmail: %s/test/fakesendmail\n' "$srcdir" >>"$mts_fakesendmail"
29 MHMTSCONF
="$mts_fakesendmail"
31 # argument: expected output
34 run_prog send
-draft -mts sendmail
/pipe
36 # fakesendmail drops the message and any cc's into this mbox.
37 mbox
="${MH_TEST_DIR}"/Mail
/fakesendmail.mbox
38 inc
-silent -file "$mbox"
39 rm -f "$mbox" "$mbox.map"
42 # It's hard to calculate the exact Date: header post is going to
43 # use, so we'll just use sed to remove the actual date so we can easily
44 # compare it against our "correct" output. And same for charset.
46 sed -e 's/^Date:.*/Date:/' -e 's/; charset="[^;]*//' \
47 "`mhpath cur`" > "${testname}.actual"
49 check
"${testname}.actual" "$1"
53 # check that 7-bit body isn't encoded
54 start_test
"7-bit body isn't encoded"
55 cat > "${MH_TEST_DIR}/attachment.txt" <<EOF
59 cat > "${MH_TEST_DIR}/Mail/draft" <<EOF
60 From: Mr Nobody <nobody@example.com>
61 To: Somebody <somebody@example.com>
63 Attach: $MH_TEST_DIR/attachment.txt
68 cat > "${testname}.expected" <<EOF
69 From: Mr Nobody <nobody@example.com>
70 To: Somebody <somebody@example.com>
73 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
77 Content-Type: text/plain
82 Content-Type: text/plain; name="attachment.txt"
83 Content-Description: attachment.txt
84 Content-Disposition: attachment; filename="attachment.txt"
88 ------- =_aaaaaaaaaa0--
91 test_attachment
"${testname}.expected"
94 # check that 8-bit body is encoded as quoted-printable text/plain,
95 # even with an attachment
96 start_test
'8-bit body is encoded as quoted-printable text/plain'
97 cat > "${MH_TEST_DIR}/Mail/draft" <<EOF
98 From: Mr Nobody <nobody@example.com>
99 To: Somebody <somebody@example.com>
101 Attach: $MH_TEST_DIR/attachment.txt
106 cat > "${testname}.expected" <<EOF
107 From: Mr Nobody <nobody@example.com>
108 To: Somebody <somebody@example.com>
111 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
112 Content-Transfer-Encoding: 8bit
115 ------- =_aaaaaaaaaa0
116 Content-Type: text/plain
117 Content-Transfer-Encoding: 8bit
121 ------- =_aaaaaaaaaa0
122 Content-Type: text/plain; name="attachment.txt"
123 Content-Description: attachment.txt
124 Content-Disposition: attachment; filename="attachment.txt"
126 this is an attachment
128 ------- =_aaaaaaaaaa0--
131 test_attachment
"${testname}.expected"
134 # check that 8-bit attachment gets C-T-E
135 start_test
'8-bit attachment gets C-T-E'
136 rm -f "${MH_TEST_DIR}/attachment.txt"
137 cat > "${MH_TEST_DIR}/attachment.txt" <<EOF
138 8-bit attachment, ¡Ay, caramba!
141 cat > "${MH_TEST_DIR}/Mail/draft" <<EOF
142 From: Mr Nobody <nobody@example.com>
143 To: Somebody <somebody@example.com>
145 Attach: $MH_TEST_DIR/attachment.txt
148 cat > "${testname}.expected" <<EOF
149 From: Mr Nobody <nobody@example.com>
150 To: Somebody <somebody@example.com>
153 Content-Type: text/plain; name="attachment.txt"
154 Content-Description: attachment.txt
155 Content-Disposition: attachment; filename="attachment.txt"
156 Content-Transfer-Encoding: 8bit
159 8-bit attachment, ¡Ay, caramba!
162 test_attachment
"${testname}.expected"
165 # check 8-bit body but make sure that the locale is set to C, which
166 # should cause mhbuild to fail
167 start_test
'8-bit body with C locale'
168 cat > "${MH_TEST_DIR}/Mail/draft" <<EOF
169 From: Mr Nobody <nobody@example.com>
170 To: Somebody <somebody@example.com>
172 Attach: $MH_TEST_DIR/attachment.txt
177 LC_ALL
="C"; export LC_ALL
180 run_prog send
-draft -mts sendmail
/pipe
> "$actual" 2>&1
183 cat > "$expected" <<EOF
184 mhbuild: Text content contains 8 bit characters, but character set is US-ASCII
185 ${MH_INST_DIR}${bindir}/mhbuild: exit 1
188 check
"$expected" "$actual"
191 rm -f ${MHMTSCONF} "${MH_TEST_DIR}/attachment.txt"
196 # emacs hackage to ensure that it writes the inverted exclamation
197 # point as UTF-8 multibyte character \xC2\xA1 instead of just \xA1.