]> diplodocus.org Git - nmh/blob - test/mhshow/test-textcharset
Remove support for -pause/-nopause switches to mhshow(1). This and
[nmh] / test / mhshow / test-textcharset
1 #!/bin/sh
2 ##########################################################
3 #
4 # Test display of text/plain parts with charset conversion
5 #
6 ##########################################################
7
8 set -e
9
10 if test -z "${MH_OBJ_DIR}"; then
11 srcdir=`dirname "$0"`/../..
12 MH_OBJ_DIR=`cd "$srcdir" && pwd`; export MH_OBJ_DIR
13 fi
14
15 . "$MH_OBJ_DIR/test/common.sh"
16
17 setup_test
18
19 if test "$ICONV_ENABLED" -eq 0; then
20 test_skip 'test-textcharset requires that nmh have been built with iconv'
21 fi
22
23 LC_ALL=en_US.UTF-8; export LC_ALL
24
25 expected="$MH_TEST_DIR"/$$.expected
26 actual="$MH_TEST_DIR"/$$.actual
27
28 # check charset conversion
29 msgfile=`mhpath new`
30 cat >"$msgfile" <<'EOF'
31 From: foo@example.edu
32 To: bar@example.edu
33 Subject: test display with charset conversion
34 MIME-Version: 1.0
35 Content-Type: text/plain; charset=windows-1252
36 Content-Transfer-Encoding: quoted-printable
37 Date: Sun, 18 Dec 2005 00:52:39 +0100
38
39 4 =F7 2 =3D 2
40 EOF
41
42 cat >"$expected" <<'EOF'
43 Date: Sun, 18 Dec 2005 00:52:39 +0100
44 To: bar@example.edu
45 From: foo@example.edu
46 Subject: test display with charset conversion
47
48 MIME-Version: 1.0
49
50 part text/plain 10
51 4 รท 2 = 2
52 EOF
53
54 run_prog mhshow last >"$actual" 2>&1
55 check "$expected" "$actual"
56
57 cat >>"$MH" <<'EOF'
58 mhshow-show-text/plain: echo %{charset}
59 EOF
60
61
62 # check expansion of %{charset} by itself
63 msgfile=`mhpath new`
64 cat >"$msgfile" <<'EOF'
65 From: foo@example.edu
66 To: bar@example.edu
67 Subject: test display with %{charset} expansion
68 MIME-Version: 1.0
69 Content-Type: text/plain; charset=windows-1252
70 Content-Transfer-Encoding: quoted-printable
71 Date: Sun, 18 Dec 2005 00:52:39 +0100
72
73 4 =F7 2 =3D 2
74 EOF
75
76 cat >"$expected" <<'EOF'
77 Date: Sun, 18 Dec 2005 00:52:39 +0100
78 To: bar@example.edu
79 From: foo@example.edu
80 Subject: test display with %{charset} expansion
81
82 MIME-Version: 1.0
83
84 UTF-8
85 EOF
86
87 run_prog mhshow last >"$actual" 2>&1
88 check "$expected" "$actual"
89
90
91 # check expansion of empty %{charset} by itself
92 msgfile=`mhpath new`
93 cat >"$msgfile" <<'EOF'
94 From: foo@example.edu
95 To: bar@example.edu
96 Subject: test display with empty %{charset} expansion
97 MIME-Version: 1.0
98 Content-Type: text/plain
99 Content-Transfer-Encoding: quoted-printable
100 Date: Sun, 18 Dec 2005 00:52:39 +0100
101
102 4 =F7 2 =3D 2
103 EOF
104
105 cat >"$expected" <<'EOF'
106 Date: Sun, 18 Dec 2005 00:52:39 +0100
107 To: bar@example.edu
108 From: foo@example.edu
109 Subject: test display with empty %{charset} expansion
110
111 MIME-Version: 1.0
112
113
114 EOF
115
116 run_prog mhshow last >"$actual" 2>&1
117 check "$expected" "$actual"
118
119
120 grep -v 'mhshow-show-text/plain:' "$MH" >"$MH.new"
121 mv -f "$MH.new" "$MH"
122 cat >>"$MH" <<'EOF'
123 mhshow-show-text/plain: charset=%{charset}; echo ${charset:+-I $charset}
124 EOF
125
126 # check expansion of embedded %{charset} with no text following
127 cat >"$expected" <<'EOF'
128 Date: Sun, 18 Dec 2005 00:52:39 +0100
129 To: bar@example.edu
130 From: foo@example.edu
131 Subject: test display with %{charset} expansion
132
133 MIME-Version: 1.0
134
135 -I UTF-8
136 EOF
137
138 run_prog mhshow prev >"$actual" 2>&1
139 check "$expected" "$actual"
140
141
142 # check expansion of empty embedded %{charset} with no text following
143 cat >"$expected" <<'EOF'
144 Date: Sun, 18 Dec 2005 00:52:39 +0100
145 To: bar@example.edu
146 From: foo@example.edu
147 Subject: test display with empty %{charset} expansion
148
149 MIME-Version: 1.0
150
151
152 EOF
153
154 run_prog mhshow last >"$actual" 2>&1
155 check "$expected" "$actual"
156
157
158 sed -e 's%\(mhshow-show-text/plain:.*\)%\1 file%' "$MH" >"$MH.new"
159 mv -f "$MH.new" "$MH"
160
161 # check expansion of embedded %{charset} with text following
162 cat >"$expected" <<'EOF'
163 Date: Sun, 18 Dec 2005 00:52:39 +0100
164 To: bar@example.edu
165 From: foo@example.edu
166 Subject: test display with %{charset} expansion
167
168 MIME-Version: 1.0
169
170 -I UTF-8 file
171 EOF
172
173 run_prog mhshow prev >"$actual" 2>&1
174 check "$expected" "$actual"
175
176
177 # check expansion of empty embedded %{charset} with text following
178 cat >"$expected" <<'EOF'
179 Date: Sun, 18 Dec 2005 00:52:39 +0100
180 To: bar@example.edu
181 From: foo@example.edu
182 Subject: test display with empty %{charset} expansion
183
184 MIME-Version: 1.0
185
186 file
187 EOF
188
189 run_prog mhshow last >"$actual" 2>&1
190 check "$expected" "$actual"
191
192
193 sed -e 's/charset/method/g' "$MH" >"$MH.new"
194 mv -f "$MH.new" "$MH"
195
196 # check parameter value quoting
197 msgfile=`mhpath new`
198 cat >"$msgfile" <<'EOF'
199 From: foo@example.edu
200 To: bar@example.edu
201 Subject: test C-T parameter expansion quoting
202 MIME-Version: 1.0
203 Content-Type: text/plain; method=$QUOTEME'
204 Content-Transfer-Encoding: quoted-printable
205 Date: Sun, 18 Dec 2005 00:52:39 +0100
206
207 4 =F7 2 =3D 2
208 EOF
209
210 cat >"$expected" <<'EOF'
211 Date: Sun, 18 Dec 2005 00:52:39 +0100
212 To: bar@example.edu
213 From: foo@example.edu
214 Subject: test C-T parameter expansion quoting
215
216 MIME-Version: 1.0
217
218 -I $QUOTEME' file
219 EOF
220
221 run_prog mhshow last >"$actual" 2>&1
222 check "$expected" "$actual"
223
224
225 sed -e 's/method/unknown/g' "$MH" >"$MH.new"
226 mv -f "$MH.new" "$MH"
227
228 # check that unknown parameter is not expanded
229 msgfile=`mhpath new`
230 cat >"$msgfile" <<'EOF'
231 From: foo@example.edu
232 To: bar@example.edu
233 Subject: test display with unknown C-T parameter expansion
234 MIME-Version: 1.0
235 Content-Type: text/plain; charset=windows-1252
236 Content-Transfer-Encoding: quoted-printable
237 Date: Sun, 18 Dec 2005 00:52:39 +0100
238
239 4 =F7 2 =3D 2
240 EOF
241
242 cat >"$expected" <<'EOF'
243 Date: Sun, 18 Dec 2005 00:52:39 +0100
244 To: bar@example.edu
245 From: foo@example.edu
246 Subject: test display with unknown C-T parameter expansion
247
248 MIME-Version: 1.0
249
250 file
251 EOF
252
253 run_prog mhshow last >"$actual" 2>&1
254 check "$expected" "$actual"
255
256
257 grep -v '^mhshow-show-text/plain: ' "$MH" >>"$MH.new"
258 mv -f "$MH.new" "$MH"
259 cat >>"$MH" <<EOF
260 mhshow-show-text/plain: true '%F' %F
261 EOF
262
263 # check parameter value quoting with text following
264 msgfile=`mhpath new`
265 cat >"$msgfile" <<'EOF'
266 From: foo@example.edu
267 To: bar@example.edu
268 Subject: check parameter value quoting with text following
269 MIME-Version: 1.0
270 Content-Type: text/plain
271 Date: Sun, 18 Dec 2005 00:52:39 +0100
272
273 This is a test.
274 EOF
275
276 cat >"$expected" <<'EOF'
277 Date: Sun, 18 Dec 2005 00:52:39 +0100
278 To: bar@example.edu
279 From: foo@example.edu
280 Subject: check parameter value quoting with text following
281
282 MIME-Version: 1.0
283
284 EOF
285
286 run_prog mhshow last >"$actual" 2>&1
287 check "$expected" "$actual"
288
289
290 exit $failed