]>
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 LC_ALL
=en_US.UTF
-8; export LC_ALL
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"
51 # check that 7-bit body isn't encoded
52 cat > "${MH_TEST_DIR}/attachment.txt" <<EOF
56 cat > "${MH_TEST_DIR}/Mail/draft" <<EOF
57 From: Mr Nobody <nobody@example.com>
58 To: Somebody <somebody@example.com>
60 Attach: $MH_TEST_DIR/attachment.txt
65 cat > "${testname}.expected" <<EOF
66 From: Mr Nobody <nobody@example.com>
67 To: Somebody <somebody@example.com>
70 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
74 Content-Type: text/plain
79 Content-Type: text/plain; name="attachment.txt"
80 Content-Description: attachment.txt
81 Content-Disposition: attachment; filename="attachment.txt"
85 ------- =_aaaaaaaaaa0--
88 test_attachment
"${testname}.expected"
90 # check that 8-bit body is encoded as quoted-printable text/plain,
91 # even with an attachment
93 cat > "${MH_TEST_DIR}/Mail/draft" <<EOF
94 From: Mr Nobody <nobody@example.com>
95 To: Somebody <somebody@example.com>
97 Attach: $MH_TEST_DIR/attachment.txt
102 cat > "${testname}.expected" <<EOF
103 From: Mr Nobody <nobody@example.com>
104 To: Somebody <somebody@example.com>
107 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
108 Content-Transfer-Encoding: 8bit
111 ------- =_aaaaaaaaaa0
112 Content-Type: text/plain
113 Content-Transfer-Encoding: 8bit
117 ------- =_aaaaaaaaaa0
118 Content-Type: text/plain; name="attachment.txt"
119 Content-Description: attachment.txt
120 Content-Disposition: attachment; filename="attachment.txt"
122 this is an attachment
124 ------- =_aaaaaaaaaa0--
127 test_attachment
"${testname}.expected"
129 # Repeat the previous test, but make sure that the locale is set to C, which
130 # should cause mhbuild to fail
132 cat > "${MH_TEST_DIR}/Mail/draft" <<EOF
133 From: Mr Nobody <nobody@example.com>
134 To: Somebody <somebody@example.com>
136 Attach: $MH_TEST_DIR/attachment.txt
141 LC_ALL
="C"; export LC_ALL
144 run_prog send
-draft -mts sendmail
/pipe
> "$actual" 2>&1
147 cat > "$expected" <<EOF
148 mhbuild: Text content contains 8 bit characters, but character set is US-ASCII
149 ${MH_INST_DIR}${bindir}/mhbuild: exit 1
152 check
"$expected" "$actual"
154 rm -f ${MHMTSCONF} "${MH_TEST_DIR}/attachment.txt"
158 # emacs hackage to ensure that it writes the inverted exclamation
159 # point as UTF-8 multibyte character \xC2\xA1 instead of just \xA1.