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().
99 Content-Type: text/plain; charset*=EBCDIC-US''%e4%e3%c6%60%f8
100 Content-Transfer-Encoding: quoted-printable
101 Content-Description: bogus quoted-printable data
102 Date: Sun, 18 Dec 2005 00:52:39 +0100
107 cat > $expected <<EOF
109 Date: Sun, 18 Dec 2005 00:52:39 +0100
111 From: foo@example.edu
115 Content-Description: bogus quoted-printable data
117 [ part - text/plain - bogus quoted-printable data 11B ]
121 run_prog mhshow $msgnum > $actual 2>&1
122 check "$expected" "$actual" : encoded parameter value
125 start_test 'replacement character in parameter value'
126 #### The output of this test doesn't show it, but it covers the
127 #### noiconv: portion of get_param_value().
128 cat > $msgfile <<'EOF'
129 Subject: invalid parameter value charset
131 Content-Type: text/plain; charset*=invalid''%0Dus-ascii
134 cat > $expected <<EOF
136 Subject: invalid parameter value charset
140 [ part - text/plain - 0B ]
143 run_prog mhshow $msgnum > $actual 2>&1
144 if [ $iconv_elides_question_marks -eq 1 ]; then
145 check "$expected" "$actual"
147 grep "Can't convert .*us-ascii to UTF-8" "$actual" >/dev/null || failed=1