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 library used on FreeBSD/NetBSD
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 #### RFC 2231 defines the extended value syntax:
85 #### extended-initial-value := [charset] "'" [language] "'"
86 #### extended-other-values
87 #### used below, where language is blank.
89 start_test
'Encoded parameter value'
91 msgnum
=`basename $msgfile`
92 #### Use a charset to exercise the iconv code, if it's available,
93 #### in get_param_value(). The Content-Type charset is UTF-8, encoded
94 #### to exercise iconv.
100 Content-Type: text/plain; charset*=ISO-2022-KR''%1b%24%29%43%55%54%46%2d%38
101 Content-Transfer-Encoding: quoted-printable
102 Content-Description: bogus quoted-printable data
103 Date: Sun, 18 Dec 2005 00:52:39 +0100
108 cat > $expected <<EOF
110 Date: Sun, 18 Dec 2005 00:52:39 +0100
112 From: foo@example.edu
116 Content-Description: bogus quoted-printable data
118 [ part - text/plain - bogus quoted-printable data 11B ]
122 if test "$ICONV_ENABLED" -eq 1; then
123 run_prog mhshow
$msgnum > $actual 2>&1
124 check
"$expected" "$actual" : encoded parameter value
128 start_test
'replacement character in parameter value'
129 #### The output of this test doesn't show it, but it covers the
130 #### noiconv: portion of get_param_value().
131 cat > $msgfile <<'EOF'
132 Subject: invalid parameter value charset
134 Content-Type: text/plain; charset*=invalid''%0Dus-ascii
137 cat > $expected <<EOF
139 Subject: invalid parameter value charset
143 [ part - text/plain - 0B ]
146 run_prog mhshow
$msgnum > $actual 2>&1
147 if [ $iconv_elides_question_marks -eq 1 ]; then
148 check
"$expected" "$actual"
149 elif grep "Can't convert .*us-ascii to UTF-8" "$actual" >/dev
/null
; then
152 echo 'iconv complaint not found'