]> diplodocus.org Git - nmh/blob - test/repl/test-convert
forw.man, mh-mime.man: Add missing commas in `SEE ALSO' list.
[nmh] / test / repl / test-convert
1 #!/bin/sh
2 ######################################################
3 #
4 # Test repl -convertarg
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 . "${srcdir}/test/post/test-post-common.sh"
16
17 expected="$MH_TEST_DIR/test-convert$$.expected"
18 actual=`mhpath +`/draft
19
20 printf 'Local-Mailbox: recipient@example.com\n' >>"$MH"
21
22
23 #### Make sure that this works with 7-bit encoding.
24 LC_ALL=C; export LC_ALL
25
26
27 # check -convertarg with multiple parts and additional text in draft
28 start_test '-convertarg with multiple parts and additional text in draft'
29 cat >"$expected" <<'EOF'
30 From: recipient@example.com
31 To: sender@example.com
32 cc:
33 Fcc: +outbox
34 Subject: Re: test
35 Comments: In-reply-to sender@example.com
36 message dated "Thu, 11 Dec 2014 08:19:02 -0600."
37 MIME-Version: 1.0
38 Content-Type: text/plain; charset="US-ASCII"
39
40 > This is part 1.
41
42 > This is part 2.
43 EOF
44
45 cat >`mhpath new` <<'EOF'
46 From: sender@example.com
47 To: recipient@example.com
48 Subject: test
49 Date: Thu, 11 Dec 2014 08:19:02 -0600
50 Content-Type: multipart/mixed; boundary="_001_"
51 MIME-Version: 1.0
52
53 --_001_
54 Content-Type: text/plain
55
56 This is part 1.
57
58 --_001_
59 Content-Type: text/plain
60
61 This is part 2.
62
63 --_001_
64 Content-Type: text/enriched
65
66 This should not appear in the reply
67 because the content type isn't matched.
68
69 --_001_--
70 EOF
71
72 repl -noformat -convertarg text/plain '' -nowhatnowproc last
73 mhbuild "$actual"
74 check "$actual" "$expected"
75
76
77 # check that text is quoted-printable encoded due to long text line
78 # This tests the setting of reply_ct->c_reqencoding and
79 # (*text_plain_ct)->c_reqencoding in expand_pseudoheader().
80 start_test "encode text as quoted-printable due to long text line"
81 cat >"$expected" <<'EOF'
82 From: recipient@example.com
83 To: sender@example.com
84 cc:
85 Fcc: +outbox
86 Subject: Re: test
87 Comments: In-reply-to sender@example.com
88 message dated "Thu, 11 Dec 2014 08:19:02 -0600."
89 MIME-Version: 1.0
90 Content-Type: text/plain; charset="US-ASCII"
91 Content-Transfer-Encoding: quoted-printable
92
93 sender@example.com writes:
94
95 > This is a very, very, very, very, very, very, very, very, very, very, ve=
96 ry, long line.
97 EOF
98
99 cat >`mhpath new` <<'EOF'
100 From: sender@example.com
101 To: recipient@example.com
102 Subject: test
103 Date: Thu, 11 Dec 2014 08:19:02 -0600
104 Content-Type: multipart/mixed; boundary="_001_"
105 MIME-Version: 1.0
106
107 --_001_
108 Content-Type: text/plain
109
110 This is a very, very, very, very, very, very, very, very, very, very, very, long line.
111
112 --_001_--
113 EOF
114
115 #### Just prefix the text with "> ".
116 cp "${MH}" "${MH}.new"
117 cat >>"${MH}.new" <<EOF
118 mhbuild-convert-text: sed 's/^\(.\)/> \1/; s/^$/>/;' <%F
119 EOF
120 repl -filter mhl.replywithoutbody -convertarg text/plain '' \
121 -nowhatnowproc last
122 MH="${MH}.new" mhbuild "$actual"
123 rm "${MH}.new"
124 check "$actual" "$expected"
125
126
127 #### Make sure that this works with 8-bit encoding.
128 finish_test
129 require_locale en_US.UTF-8 en_US.UTF8 en_US.utf-8 en_US.utf8
130
131
132 # check -convertarg with multiple parts, 7 bit
133 start_test '-convertarg with multiple parts, 7 bit'
134 cat >"$expected" <<'EOF'
135 From: recipient@example.com
136 To: sender@example.com
137 cc:
138 Fcc: +outbox
139 Subject: Re: test
140 Comments: In-reply-to sender@example.com
141 message dated "Thu, 11 Dec 2014 08:19:02 -0600."
142 MIME-Version: 1.0
143 Content-Type: text/plain; charset="UTF-8"
144
145 sender@example.com writes:
146
147 > This is part 1.
148
149 > This is part 2.
150 EOF
151
152 cat >`mhpath new` <<'EOF'
153 From: sender@example.com
154 To: recipient@example.com
155 Subject: test
156 Date: Thu, 11 Dec 2014 08:19:02 -0600
157 Content-Type: multipart/mixed; boundary="_001_"
158 MIME-Version: 1.0
159
160 --_001_
161 Content-Type: text/plain
162
163 This is part 1.
164
165 --_001_
166 Content-Type: text/plain; charset="UTF-8"
167
168 This is part 2.
169
170 --_001_--
171 EOF
172
173 repl -filter mhl.replywithoutbody -convertarg text/plain '' -nowhatnowproc last
174 mhbuild "$actual"
175 check "$actual" "$expected"
176
177
178 # check -convertarg with multiple parts, 8 bit
179 start_test '-convertarg with multiple parts, 8 bit'
180 cat >"$expected" <<'EOF'
181 From: recipient@example.com
182 To: sender@example.com
183 cc:
184 Fcc: +outbox
185 Subject: Re: test
186 Comments: In-reply-to sender@example.com
187 message dated "Thu, 11 Dec 2014 08:19:02 -0600."
188 MIME-Version: 1.0
189 Content-Type: text/plain; charset="UTF-8"
190 Content-Transfer-Encoding: 8bit
191
192 sender@example.com writes:
193
194 > This is part 1.
195
196 > This is §2, with a non-ASCII character.
197 EOF
198
199 cat >`mhpath new` <<'EOF'
200 From: sender@example.com
201 To: recipient@example.com
202 Subject: test
203 Date: Thu, 11 Dec 2014 08:19:02 -0600
204 Content-Type: multipart/mixed; boundary="_001_"
205 MIME-Version: 1.0
206
207 --_001_
208 Content-Type: text/plain
209
210 This is part 1.
211
212 --_001_
213 Content-Type: text/plain; charset="UTF-8"
214
215 This is §2, with a non-ASCII character.
216
217 --_001_--
218 EOF
219
220 repl -filter mhl.replywithoutbody -convertarg text/plain '' -nowhatnowproc last
221 mhbuild "$actual"
222 check "$actual" "$expected"
223
224
225 # check message with text part in multipart/related
226 start_test 'check message with text part in multipart/related'
227 cat >"$expected" <<'EOF'
228 From: recipient@example.com
229 To: sender@example.com
230 cc:
231 Fcc: +outbox
232 Subject: Re: test with text part in multipart/related
233 Comments: In-reply-to sender@example.com
234 message dated "."
235 MIME-Version: 1.0
236 Content-Type: text/plain; charset="UTF-8"
237
238 sender@example.com writes:
239
240 > This is a test.
241 EOF
242
243 cat >`mhpath new` <<'EOF'
244 From: sender@example.com
245 To: recipient@example.com
246 Subject: test with text part in multipart/related
247 Content-Type: multipart/alternative; boundary="_001_"
248 MIME-Version: 1.0
249
250 --_001_
251 Content-Type: multipart/related; type="text/plain"; boundary="_002_"
252
253 --_002_
254 Content-Type: text/plain; charset="UTF-8"
255
256 This is a test.
257
258 --_002_--
259
260 --_001_--
261 EOF
262
263 repl -filter mhl.replywithoutbody -convertarg text/plain '' -nowhatnowproc last
264 mhbuild "$actual"
265 check "$actual" "$expected"
266
267
268 # check reply to calendar request
269 start_test 'check reply to calendar request'
270 cat >"$expected" <<'EOF'
271 From: recipient@example.com
272 To: sender@example.com
273 cc:
274 Fcc: +outbox
275 Subject: Re: test iCalendar reply
276 Comments: In-reply-to sender@example.com
277 message dated "."
278 MIME-Version: 1.0
279 Content-Type: text/calendar; method="REPLY"; charset="UTF-8"
280
281 BEGIN:VCALENDAR
282 METHOD:REPLY
283 PRODID:nmh mhical v0.1
284 VERSION:2.0
285 BEGIN:VTIMEZONE
286 TZID:Eastern Standard Time
287 BEGIN:STANDARD
288 DTSTART:16010101T020000
289 TZOFFSETFROM:-0400
290 TZOFFSETTO:-0500
291 RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=1SU;BYMONTH=11
292 END:STANDARD
293 BEGIN:DAYLIGHT
294 DTSTART:16010101T020000
295 TZOFFSETFROM:-0500
296 TZOFFSETTO:-0400
297 RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=2SU;BYMONTH=3
298 END:DAYLIGHT
299 END:VTIMEZONE
300 BEGIN:VEVENT
301 ORGANIZER;CN=Requester:MAILTO:requester@example.com
302 ATTENDEE;PARTSTAT=ACCEPTED;CN=Recip:MAILTO:recipient@example.com
303 SUMMARY;LANGUAGE=en-US:Accepted: test request
304 DTSTART;TZID=Eastern Standard Time:20150105T090000
305 DTEND;TZID=Eastern Standard Time:20150105T093000
306 UID:0123456789
307 CLASS:PUBLIC
308 PRIORITY:5
309 TRANSP:OPAQUE
310 STATUS:CONFIRMED
311 SEQUENCE:0
312 LOCATION;LANGUAGE=en-US:
313 END:VEVENT
314 END:VCALENDAR
315 EOF
316
317 cat >`mhpath new` <<'EOF'
318 From: sender@example.com
319 To: recipient@example.com
320 Subject: test iCalendar reply
321 Content-Type: text/calendar; charset="UTF-8"
322 MIME-Version: 1.0
323
324 BEGIN:VCALENDAR
325 METHOD:REQUEST
326 PRODID:test-convert
327 VERSION:2.0
328 BEGIN:VTIMEZONE
329 TZID:Eastern Standard Time
330 BEGIN:STANDARD
331 DTSTART:16010101T020000
332 TZOFFSETFROM:-0400
333 TZOFFSETTO:-0500
334 RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=1SU;BYMONTH=11
335 END:STANDARD
336 BEGIN:DAYLIGHT
337 DTSTART:16010101T020000
338 TZOFFSETFROM:-0500
339 TZOFFSETTO:-0400
340 RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=2SU;BYMONTH=3
341 END:DAYLIGHT
342 END:VTIMEZONE
343 BEGIN:VEVENT
344 ORGANIZER;CN=Requester:MAILTO:requester@example.com
345 ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN=Requestee1
346 :MAILTO:requestee1@example.com
347 ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN=Requestee2
348 :MAILTO:requestee2@example.com
349 ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN=Requestee3
350 :MAILTO:requestee3@example.com
351 SUMMARY;LANGUAGE=en-US:test request
352 DTSTART;TZID=Eastern Standard Time:20150105T090000
353 DTEND;TZID=Eastern Standard Time:20150105T093000
354 UID:0123456789
355 CLASS:PUBLIC
356 PRIORITY:5
357 DTSTAMP:20150101T171600Z
358 TRANSP:OPAQUE
359 STATUS:CONFIRMED
360 SEQUENCE:0
361 LOCATION;LANGUAGE=en-US:
362 BEGIN:VALARM
363 ACTION:DISPLAY
364 DESCRIPTION:REMINDER
365 TRIGGER;RELATED=START:-PT15M
366 END:VALARM
367 END:VEVENT
368 END:VCALENDAR
369 EOF
370
371 actual="$MH_TEST_DIR/test-convert$$.actual"
372 repl -noformat \
373 -convertargs text/calendar '-reply accept -contenttype' -nowhatnowproc last
374 SIGNATURE=Recip mhbuild - <`mhpath +`/draft | egrep -v '^DTSTAMP:' >"$actual"
375 check "$actual" "$expected"
376
377
378 finish_test
379 exit $failed