2 ######################################################
4 # Test charset conversion functionality
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"
19 check_exit
'-eq 1' mhshow
-
21 require_locale en_US.UTF
-8 en_US.UTF8 en_US.utf
-8 en_US.utf8
23 iconv_elides_question_marks
=0
24 if test "$ICONV_ENABLED" -eq 0; then
28 #### The GNU iconv library normalises charset names by eliding '?', along
29 #### with some other characters. The iconv libraries used on FreeBSD/NetBSD
30 #### and Mac OS X don't.
31 printf x
| iconv -f '?UTF-8' -t UTF
-8 >/dev
/null
2>&1 &&
32 iconv_elides_question_marks
=1
35 expected
=$MH_TEST_DIR/$$.expected
36 actual
=$MH_TEST_DIR/$$.actual
38 echo 'mhshow-charset-windows-1252: echo "This is a test"' >> "$MH"
40 # Write message with bogus quoted-printable data.
41 start_test
'Write message with bogus quoted-printable data'
43 msgnum
=`basename $msgfile`
49 Content-Type: text/plain; charset=windows-1252
50 Content-Transfer-Encoding: quoted-printable
51 Content-Description: bogus quoted-printable data
52 Date: Sun, 18 Dec 2005 00:52:39 +0100
59 Date: Sun, 18 Dec 2005 00:52:39 +0100
65 Content-Description: bogus quoted-printable data
67 [ part - text/plain - bogus quoted-printable data ${text_size}B ]
71 run_prog mhshow
$msgnum > $actual 2>&1
72 check
"$expected" "$actual" 'keep first' : bogus quoted
-printable data
75 start_test
'locale profile component'
76 #### Used LC_ALL above, now use locale profile component instead.
77 printf "locale: $LC_ALL\n" >> "${MH}"
80 run_prog mhshow
$msgnum > $actual 2>&1
81 check
"$expected" "$actual" : locale profile component
84 #### All of the remaining tests rely on iconv.a
85 if test "$ICONV_ENABLED" -eq 0; then
91 #### RFC 2231 defines the extended value syntax:
92 #### extended-initial-value := [charset] "'" [language] "'"
93 #### extended-other-values
94 #### used below, where language is blank.
96 start_test
'Encoded parameter value'
98 msgnum
=`basename $msgfile`
99 #### Use a charset to exercise the iconv code, if it's available,
100 #### in get_param_value(). The Content-Type charset is UTF-8, encoded
101 #### to exercise iconv.
103 From: foo@example.edu
107 Content-Type: text/plain; charset*=ISO-2022-KR''%1b%24%29%43%55%54%46%2d%38
108 Content-Transfer-Encoding: quoted-printable
109 Content-Description: bogus quoted-printable data
110 Date: Sun, 18 Dec 2005 00:52:39 +0100
115 cat > $expected <<EOF
117 Date: Sun, 18 Dec 2005 00:52:39 +0100
119 From: foo@example.edu
123 Content-Description: bogus quoted-printable data
125 [ part - text/plain - bogus quoted-printable data 11B ]
129 run_prog mhshow
$msgnum > $actual 2>&1
130 check
"$expected" "$actual" : encoded parameter value
133 #### mhshow replaces the invalid character in the charset parameter value with
134 #### a '?'. So, a charset name of "?us-ascii" is fed to iconv. If
135 #### $iconv_elides_question_marks, iconv will normalize that to "us-ascii".
136 #### Otherwise, we expect iconv to fail.
137 start_test
'replacement character in parameter value'
138 cat > $msgfile <<'EOF'
139 Subject: invalid parameter value charset
141 Content-Type: text/plain; charset*=invalid''%0Dus-ascii
144 cat > $expected <<EOF
146 Subject: invalid parameter value charset
150 [ part - text/plain - 0B ]
153 run_prog mhshow
$msgnum > $actual 2>&1
154 if [ $iconv_elides_question_marks -eq 1 ]; then
155 check
"$expected" "$actual"
157 if grep "Can't convert .*us-ascii to UTF-8" "$actual" >/dev
/null
; then
158 rm -f "$expected" "$actual"