]> diplodocus.org Git - nmh/blob - test/mhbuild/test-ext-params
Replaced setgid() calls with setegid() so that it works with dot
[nmh] / test / mhbuild / test-ext-params
1 #!/bin/sh
2 ######################################################
3 #
4 # Test the creation of RFC 2231 encoded parameters
5 #
6 ######################################################
7
8 if test -z "${MH_OBJ_DIR}"; then
9 srcdir=`dirname "$0"`/../..
10 MH_OBJ_DIR=`cd "$srcdir" && pwd`; export MH_OBJ_DIR
11 fi
12
13 . "$MH_OBJ_DIR/test/common.sh"
14
15 setup_test
16
17 require_locale en_US.utf-8 en_US.utf8
18 LC_ALL=en_US.UTF-8; export LC_ALL
19
20 draft="$MH_TEST_DIR/$$.draft"
21 backup="${MH_TEST_DIR}/`mhparam sbackup`$$.draft.orig"
22 expected="$MH_TEST_DIR/$$.expected"
23
24 #
25 # Try out a draft with some 8-bit encoded parameters
26 #
27
28 cat > "$draft" <<EOF
29 To: Mr Test <mrtest@example.com>
30 cc:
31 Fcc: +outbox
32 ------
33 This is a test message
34 #image/jpeg {attachment; filename="tïny.jpg"} ${srcdir}/test/mhbuild/tiny.jpg
35 EOF
36
37 run_prog mhbuild "$draft"
38
39 cat > "$expected" <<EOF
40 To: Mr Test <mrtest@example.com>
41 cc:
42 Fcc: +outbox
43 MIME-Version: 1.0
44 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
45
46 ------- =_aaaaaaaaaa0
47 Content-Type: text/plain; charset="us-ascii"
48
49 This is a test message
50
51 ------- =_aaaaaaaaaa0
52 Content-Type: image/jpeg
53 Content-Disposition: attachment; filename*=UTF-8''t%C3%AFny.jpg
54 Content-Transfer-Encoding: base64
55
56 /9g=
57
58 ------- =_aaaaaaaaaa0--
59 EOF
60
61 check "$draft" "$expected"
62
63 #
64 # Try out a draft with some long parameters
65 #
66
67 cat > "$draft" <<EOF
68 To: Mr Test <mrtest@example.com>
69 cc:
70 Fcc: +outbox
71 ------
72 This is a test message
73 #image/jpeg {attachment; filename="This is an example of a rather long filename that is longer than would fit on a normal line.jpg"} \
74 ${srcdir}/test/mhbuild/tiny.jpg
75 EOF
76
77 run_prog mhbuild "$draft"
78
79 cat > "$expected" <<EOF
80 To: Mr Test <mrtest@example.com>
81 cc:
82 Fcc: +outbox
83 MIME-Version: 1.0
84 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
85
86 ------- =_aaaaaaaaaa0
87 Content-Type: text/plain; charset="us-ascii"
88
89 This is a test message
90
91 ------- =_aaaaaaaaaa0
92 Content-Type: image/jpeg
93 Content-Disposition: attachment;
94 filename*0="This is an example of a rather long filename that is lo";
95 filename*1="nger than would fit on a normal line.jpg"
96 Content-Transfer-Encoding: base64
97
98 /9g=
99
100 ------- =_aaaaaaaaaa0--
101 EOF
102
103 check "$draft" "$expected"
104
105 #
106 # Try out attach with a filename with 8-bit characters
107 #
108
109 cp "${srcdir}/test/mhbuild/tiny.jpg" "$MH_TEST_DIR/tïny.jpg"
110
111 cat > "$draft" <<EOF
112 To: Mr Test <mrtest@example.com>
113 cc:
114 Fcc: +outbox
115 Attach: $MH_TEST_DIR/tïny.jpg
116 ------
117 This is a test message
118 EOF
119
120 run_prog mhbuild "$draft"
121
122 cat > "$expected" <<EOF
123 To: Mr Test <mrtest@example.com>
124 cc:
125 Fcc: +outbox
126 MIME-Version: 1.0
127 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
128
129 ------- =_aaaaaaaaaa0
130 Content-Type: text/plain; charset="us-ascii"
131
132 This is a test message
133
134 ------- =_aaaaaaaaaa0
135 Content-Type: image/jpeg; name*=UTF-8''t%C3%AFny.jpg
136 Content-Description: =?UTF-8?B?dMOvbnkuanBn?=
137 Content-Disposition: attachment; filename*=UTF-8''t%C3%AFny.jpg
138 Content-Transfer-Encoding: base64
139
140 /9g=
141
142 ------- =_aaaaaaaaaa0--
143 EOF
144
145 check "$draft" "$expected"
146
147 #
148 # Alternate version; specify a disposion, but not an explicit filename
149 #
150
151 cat > "$draft" <<EOF
152 To: Mr Test <mrtest@example.com>
153 cc:
154 Fcc: +outbox
155 ------
156 This is a test message
157 #image/jpeg {attachment} $MH_TEST_DIR/tïny.jpg
158 EOF
159
160 run_prog mhbuild "$draft"
161
162 cat > "$expected" <<EOF
163 To: Mr Test <mrtest@example.com>
164 cc:
165 Fcc: +outbox
166 MIME-Version: 1.0
167 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
168
169 ------- =_aaaaaaaaaa0
170 Content-Type: text/plain; charset="us-ascii"
171
172 This is a test message
173
174 ------- =_aaaaaaaaaa0
175 Content-Type: image/jpeg
176 Content-Disposition: attachment; filename*=UTF-8''t%C3%AFny.jpg
177 Content-Transfer-Encoding: base64
178
179 /9g=
180
181 ------- =_aaaaaaaaaa0--
182 EOF
183
184 check "$draft" "$expected"
185
186 #
187 # Test to make sure things fail if we try to put 8-bit characters when the
188 # locale is US-ASCII
189 #
190
191 cat > "$draft" <<EOF
192 To: Mr Test <mrtest@example.com>
193 cc:
194 Fcc: +outbox
195 ------
196 This is a test message
197 #image/jpeg {attachment} $MH_TEST_DIR/tïny.jpg
198 EOF
199
200 old_locale="$LC_ALL"
201 LC_ALL=C; export LC_ALL
202
203 set +e
204 run_test 'eval mhbuild "$draft" 2>&1' 'mhbuild: 8-bit characters in parameter "filename", but local character set is US-ASCII'
205 set -e
206
207 LC_ALL="$old_locale"; export LC_ALL
208
209 rm -f "$MH_TEST_DIR/tïny.jpg"
210
211 #
212 # Test out message/external-body decoding
213 #
214
215 cat > "$draft" <<EOF
216 To: Mr Test <mrtest@example.com>
217 cc:
218 Fcc: +outbox
219 ------
220 This is a test message
221 #@application/octet-stream [Test of a long URL] {attachment; \
222 filename=test.tar.gz} access-type=url; url="http://www.example.com/this/is/an/example/of/a/very/long/url/that-should-be-wrapped/name.tar.gz"
223 EOF
224
225 run_prog mhbuild "$draft"
226
227 cat > "$expected" <<EOF
228 To: Mr Test <mrtest@example.com>
229 cc:
230 Fcc: +outbox
231 MIME-Version: 1.0
232 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
233
234 ------- =_aaaaaaaaaa0
235 Content-Type: text/plain; charset="us-ascii"
236
237 This is a test message
238
239 ------- =_aaaaaaaaaa0
240 Content-Type: message/external-body; access-type="url";
241 url*0="http://www.example.com/this/is/an/example/of/a/very/long/url";
242 url*1="/that-should-be-wrapped/name.tar.gz"
243
244 Content-Type: application/octet-stream
245 Content-Description: Test of a long URL
246 Content-Disposition: attachment; filename="test.tar.gz"
247
248 ------- =_aaaaaaaaaa0--
249 EOF
250
251 check "$draft" "$expected"
252
253 [ ${failed:=0} -eq 0 ] && rm -f ${backup}
254
255 exit ${failed:-0}