]>
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"
52 # check that 7-bit body isn't encoded
53 cat > "${MH_TEST_DIR}/attachment.txt" <<EOF
57 cat > "${MH_TEST_DIR}/Mail/draft" <<EOF
58 From: Mr Nobody <nobody@example.com>
59 To: Somebody <somebody@example.com>
61 Attach: $MH_TEST_DIR/attachment.txt
66 cat > "${testname}.expected" <<EOF
67 From: Mr Nobody <nobody@example.com>
68 To: Somebody <somebody@example.com>
71 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
75 Content-Type: text/plain
80 Content-Type: text/plain; name="attachment.txt"
81 Content-Description: attachment.txt
82 Content-Disposition: attachment; filename="attachment.txt"
86 ------- =_aaaaaaaaaa0--
89 test_attachment
"${testname}.expected"
91 # check that 8-bit body is encoded as quoted-printable text/plain,
92 # even with an attachment
94 cat > "${MH_TEST_DIR}/Mail/draft" <<EOF
95 From: Mr Nobody <nobody@example.com>
96 To: Somebody <somebody@example.com>
98 Attach: $MH_TEST_DIR/attachment.txt
103 cat > "${testname}.expected" <<EOF
104 From: Mr Nobody <nobody@example.com>
105 To: Somebody <somebody@example.com>
108 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
109 Content-Transfer-Encoding: 8bit
112 ------- =_aaaaaaaaaa0
113 Content-Type: text/plain
114 Content-Transfer-Encoding: 8bit
118 ------- =_aaaaaaaaaa0
119 Content-Type: text/plain; name="attachment.txt"
120 Content-Description: attachment.txt
121 Content-Disposition: attachment; filename="attachment.txt"
123 this is an attachment
125 ------- =_aaaaaaaaaa0--
128 test_attachment
"${testname}.expected"
130 # Repeat the previous test, but make sure that the locale is set to C, which
131 # should cause mhbuild to fail
133 cat > "${MH_TEST_DIR}/Mail/draft" <<EOF
134 From: Mr Nobody <nobody@example.com>
135 To: Somebody <somebody@example.com>
137 Attach: $MH_TEST_DIR/attachment.txt
142 LC_ALL
="C"; export LC_ALL
145 run_prog send
-draft -mts sendmail
/pipe
> "$actual" 2>&1
148 cat > "$expected" <<EOF
149 mhbuild: Text content contains 8 bit characters, but character set is US-ASCII
150 ${MH_INST_DIR}${bindir}/mhbuild: exit 1
153 check
"$expected" "$actual"
155 rm -f ${MHMTSCONF} "${MH_TEST_DIR}/attachment.txt"
159 # emacs hackage to ensure that it writes the inverted exclamation
160 # point as UTF-8 multibyte character \xC2\xA1 instead of just \xA1.