]> diplodocus.org Git - nmh/blob - test/mhbuild/test-ext-params
Don't clobber "cp"; use dp instead.
[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 LC_ALL=en_US.UTF-8; export LC_ALL
18
19 draft="$MH_TEST_DIR/$$.draft"
20 backup="${MH_TEST_DIR}/`mhparam sbackup`$$.draft.orig"
21 expected="$MH_TEST_DIR/$$.expected"
22
23 #
24 # Try out a draft with some 8-bit encoded parameters
25 #
26
27 cat > "$draft" <<EOF
28 To: Mr Test <mrtest@example.com>
29 cc:
30 Fcc: +outbox
31 ------
32 This is a test message
33 #image/jpeg {attachment; filename="tïny.jpg"} ${srcdir}/test/mhbuild/tiny.jpg
34 EOF
35
36 run_prog mhbuild "$draft"
37
38 cat > "$expected" <<EOF
39 To: Mr Test <mrtest@example.com>
40 cc:
41 Fcc: +outbox
42 MIME-Version: 1.0
43 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
44
45 ------- =_aaaaaaaaaa0
46 Content-Type: text/plain; charset="us-ascii"
47
48 This is a test message
49
50 ------- =_aaaaaaaaaa0
51 Content-Type: image/jpeg
52 Content-Disposition: attachment; filename*=UTF-8''t%C3%AFny.jpg
53 Content-Transfer-Encoding: base64
54
55 /9g=
56
57 ------- =_aaaaaaaaaa0--
58 EOF
59
60 check "$draft" "$expected"
61
62 #
63 # Try out a draft with some long parameters
64 #
65
66 cat > "$draft" <<EOF
67 To: Mr Test <mrtest@example.com>
68 cc:
69 Fcc: +outbox
70 ------
71 This is a test message
72 #image/jpeg {attachment; filename="This is an example of a rather long filename that is longer than would fit on a normal line.jpg"} \
73 ${srcdir}/test/mhbuild/tiny.jpg
74 EOF
75
76 run_prog mhbuild "$draft"
77
78 cat > "$expected" <<EOF
79 To: Mr Test <mrtest@example.com>
80 cc:
81 Fcc: +outbox
82 MIME-Version: 1.0
83 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
84
85 ------- =_aaaaaaaaaa0
86 Content-Type: text/plain; charset="us-ascii"
87
88 This is a test message
89
90 ------- =_aaaaaaaaaa0
91 Content-Type: image/jpeg
92 Content-Disposition: attachment;
93 filename*0="This is an example of a rather long filename that is lo";
94 filename*1="nger than would fit on a normal line.jpg"
95 Content-Transfer-Encoding: base64
96
97 /9g=
98
99 ------- =_aaaaaaaaaa0--
100 EOF
101
102 check "$draft" "$expected"
103
104 #
105 # Try out attach with a filename with 8-bit characters
106 #
107
108 cp "${srcdir}/test/mhbuild/tiny.jpg" "$MH_TEST_DIR/tïny.jpg"
109
110 cat > "$draft" <<EOF
111 To: Mr Test <mrtest@example.com>
112 cc:
113 Fcc: +outbox
114 Attach: $MH_TEST_DIR/tïny.jpg
115 ------
116 This is a test message
117 EOF
118
119 run_prog mhbuild "$draft"
120
121 cat > "$expected" <<EOF
122 To: Mr Test <mrtest@example.com>
123 cc:
124 Fcc: +outbox
125 MIME-Version: 1.0
126 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
127
128 ------- =_aaaaaaaaaa0
129 Content-Type: text/plain; charset="us-ascii"
130
131 This is a test message
132
133 ------- =_aaaaaaaaaa0
134 Content-Type: image/jpeg; name*=UTF-8''t%C3%AFny.jpg
135 Content-Description: =?UTF-8?B?dMOvbnkuanBn?=
136 Content-Disposition: attachment; filename*=UTF-8''t%C3%AFny.jpg
137 Content-Transfer-Encoding: base64
138
139 /9g=
140
141 ------- =_aaaaaaaaaa0--
142 EOF
143
144 check "$draft" "$expected"
145
146 #
147 # Alternate version; specify a disposion, but not an explicit filename
148 #
149
150 cat > "$draft" <<EOF
151 To: Mr Test <mrtest@example.com>
152 cc:
153 Fcc: +outbox
154 ------
155 This is a test message
156 #image/jpeg {attachment} $MH_TEST_DIR/tïny.jpg
157 EOF
158
159 run_prog mhbuild "$draft"
160 rm -f "$MH_TEST_DIR/tïny.jpg"
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 out message/external-body decoding
188 #
189
190 cat > "$draft" <<EOF
191 To: Mr Test <mrtest@example.com>
192 cc:
193 Fcc: +outbox
194 ------
195 This is a test message
196 #@application/octet-stream [Test of a long URL] {attachment; \
197 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"
198 EOF
199
200 run_prog mhbuild "$draft"
201
202 cat > "$expected" <<EOF
203 To: Mr Test <mrtest@example.com>
204 cc:
205 Fcc: +outbox
206 MIME-Version: 1.0
207 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
208
209 ------- =_aaaaaaaaaa0
210 Content-Type: text/plain; charset="us-ascii"
211
212 This is a test message
213
214 ------- =_aaaaaaaaaa0
215 Content-Type: message/external-body; access-type="url";
216 url*0="http://www.example.com/this/is/an/example/of/a/very/long/url";
217 url*1="/that-should-be-wrapped/name.tar.gz"
218
219 Content-Type: application/octet-stream
220 Content-Description: Test of a long URL
221 Content-Disposition: attachment; filename="test.tar.gz"
222
223 ------- =_aaaaaaaaaa0--
224 EOF
225
226 check "$draft" "$expected"
227
228 [ ${failed:=0} -eq 0 ] && rm -f ${backup}
229
230 exit ${failed:-0}