Debian Codegraph @

test/repl/test-convert

raw
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: [email protected]\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: [email protected]
31 To: [email protected]
32 cc:
33 Fcc: +outbox
34 Subject: Re: test
35 Comments: In-reply-to [email protected]
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: [email protected]
47 To: [email protected]
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 -auto "$actual"
74 check "$actual" "$expected"
75
76
77 start_test "test ability to edit prior to encoding"
78 cat >"$expected" <<'EOF'
79 From: [email protected]
80 To: [email protected]
81 cc:
82 Fcc: +outbox
83 Subject: Re: test
84 Comments: In-reply-to [email protected]
85 message dated "Thu, 11 Dec 2014 08:19:02 -0600."
86 Nmh-check-text-encoding: unencoded
87 MIME-Version: 1.0
88 Content-Type: text/plain; charset="US-ASCII"
89
90 [email protected] writes:
91
92 > This is a very, very, very, very, very, very, very, very, very, very, very, long line.
93 EOF
94
95 cat >`mhpath new` <<'EOF'
96 From: [email protected]
97 To: [email protected]
98 Subject: test
99 Date: Thu, 11 Dec 2014 08:19:02 -0600
100 Content-Type: multipart/mixed; boundary="_001_"
101 MIME-Version: 1.0
102
103 --_001_
104 Content-Type: text/plain
105
106 This is a very, very, very, very, very, very, very, very, very, very, very, long line.
107
108 --_001_--
109 EOF
110
111 #### Just prefix the text with "> ".
112 cp "${MH}" "${MH}.new"
113 cat >>"${MH}.new" <<EOF
114 mhbuild-convert-text: sed 's/^\(.\)/> \1/; s/^$/>/;' <%F
115 EOF
116 repl -filter mhl.replywithoutbody -convertarg text/plain '' \
117 -nowhatnowproc last
118 MH="${MH}.new" mhbuild "$actual"
119 check "$actual" "$expected"
120
121
122 # check that text is quoted-printable encoded due to long text line
123 # This tests the setting of reply_ct->c_reqencoding and
124 # (*text_plain_ct)->c_reqencoding in expand_pseudoheader().
125 start_test "encode text as quoted-printable due to long text line"
126 cat >"$expected" <<'EOF'
127 From: [email protected]
128 To: [email protected]
129 cc:
130 Fcc: +outbox
131 Subject: Re: test
132 Comments: In-reply-to [email protected]
133 message dated "Thu, 11 Dec 2014 08:19:02 -0600."
134 MIME-Version: 1.0
135 Content-Type: text/plain; charset="US-ASCII"
136 Content-Transfer-Encoding: quoted-printable
137
138 [email protected] writes:
139
140 > This is a very, very, very, very, very, very, very, very, very, very, ve=
141 ry, long line.
142 EOF
143
144 repl -filter mhl.replywithoutbody -convertarg text/plain '' \
145 -nowhatnowproc last
146 MH="${MH}.new" mhbuild -auto "$actual"
147 rm "${MH}.new"
148 check "$actual" "$expected"
149
150
151 #### Make sure that this works with 8-bit encoding.
152 finish_test
153 require_locale $en_locales
154
155
156 # check -convertarg with multiple parts, 7 bit
157 start_test '-convertarg with multiple parts, 7 bit'
158 cat >"$expected" <<'EOF'
159 From: [email protected]
160 To: [email protected]
161 cc:
162 Fcc: +outbox
163 Subject: Re: test
164 Comments: In-reply-to [email protected]
165 message dated "Thu, 11 Dec 2014 08:19:02 -0600."
166 MIME-Version: 1.0
167 Content-Type: text/plain; charset="UTF-8"
168
169 [email protected] writes:
170
171 > This is part 1.
172
173 > This is part 2.
174 EOF
175
176 cat >`mhpath new` <<'EOF'
177 From: [email protected]
178 To: [email protected]
179 Subject: test
180 Date: Thu, 11 Dec 2014 08:19:02 -0600
181 Content-Type: multipart/mixed; boundary="_001_"
182 MIME-Version: 1.0
183
184 --_001_
185 Content-Type: text/plain
186
187 This is part 1.
188
189 --_001_
190 Content-Type: text/plain; charset="UTF-8"
191
192 This is part 2.
193
194 --_001_--
195 EOF
196
197 repl -filter mhl.replywithoutbody -convertarg text/plain '' -nowhatnowproc last
198 mhbuild -auto "$actual"
199 check "$actual" "$expected"
200
201
202 # check -convertarg with multiple parts, 8 bit
203 start_test '-convertarg with multiple parts, 8 bit'
204 cat >"$expected" <<'EOF'
205 From: [email protected]
206 To: [email protected]
207 cc:
208 Fcc: +outbox
209 Subject: Re: test
210 Comments: In-reply-to [email protected]
211 message dated "Thu, 11 Dec 2014 08:19:02 -0600."
212 MIME-Version: 1.0
213 Content-Type: text/plain; charset="UTF-8"
214 Content-Transfer-Encoding: 8bit
215
216 [email protected] writes:
217
218 > This is part 1.
219
220 > This is §2, with a non-ASCII character.
221 EOF
222
223 cat >`mhpath new` <<'EOF'
224 From: [email protected]
225 To: [email protected]
226 Subject: test
227 Date: Thu, 11 Dec 2014 08:19:02 -0600
228 Content-Type: multipart/mixed; boundary="_001_"
229 MIME-Version: 1.0
230
231 --_001_
232 Content-Type: text/plain
233
234 This is part 1.
235
236 --_001_
237 Content-Type: text/plain; charset="UTF-8"
238
239 This is §2, with a non-ASCII character.
240
241 --_001_--
242 EOF
243
244 repl -filter mhl.replywithoutbody -convertarg text/plain '' -nowhatnowproc last
245 mhbuild -auto "$actual"
246 check "$actual" "$expected"
247
248
249 # check message with text part in multipart/related
250 start_test 'check message with text part in multipart/related'
251 cat >"$expected" <<'EOF'
252 From: [email protected]
253 To: [email protected]
254 cc:
255 Fcc: +outbox
256 Subject: Re: test with text part in multipart/related
257 Comments: In-reply-to [email protected]
258 message dated "."
259 MIME-Version: 1.0
260 Content-Type: text/plain; charset="UTF-8"
261
262 [email protected] writes:
263
264 > This is a test.
265 EOF
266
267 cat >`mhpath new` <<'EOF'
268 From: [email protected]
269 To: [email protected]
270 Subject: test with text part in multipart/related
271 Content-Type: multipart/alternative; boundary="_001_"
272 MIME-Version: 1.0
273
274 --_001_
275 Content-Type: multipart/related; type="text/plain"; boundary="_002_"
276
277 --_002_
278 Content-Type: text/plain; charset="UTF-8"
279
280 This is a test.
281
282 --_002_--
283
284 --_001_--
285 EOF
286
287 repl -filter mhl.replywithoutbody -convertarg text/plain '' -nowhatnowproc last
288 mhbuild -auto "$actual"
289 check "$actual" "$expected"
290
291
292 # check reply to calendar request
293 start_test 'check reply to calendar request'
294 cat >"$expected" <<'EOF'
295 From: [email protected]
296 To: [email protected]
297 cc:
298 Fcc: +outbox
299 Subject: Re: test iCalendar reply
300 Comments: In-reply-to [email protected]
301 message dated "."
302 MIME-Version: 1.0
303 Content-Type: text/calendar; method="REPLY"; charset="UTF-8"
304
305 BEGIN:VCALENDAR
306 METHOD:REPLY
307 PRODID:nmh mhical v0.5
308 VERSION:2.0
309 BEGIN:VTIMEZONE
310 TZID:Eastern Standard Time
311 BEGIN:STANDARD
312 DTSTART:16010101T020000
313 TZOFFSETFROM:-0400
314 TZOFFSETTO:-0500
315 RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=1SU;BYMONTH=11
316 END:STANDARD
317 BEGIN:DAYLIGHT
318 DTSTART:16010101T020000
319 TZOFFSETFROM:-0500
320 TZOFFSETTO:-0400
321 RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=2SU;BYMONTH=3
322 END:DAYLIGHT
323 END:VTIMEZONE
324 BEGIN:VEVENT
325 ORGANIZER;CN=Requester:MAILTO:[email protected]
326 ATTENDEE;PARTSTAT=ACCEPTED;CN=Recip:MAILTO:[email protected]
327 SUMMARY;LANGUAGE=en-US:Accepted: test request
328 DTSTART;TZID=Eastern Standard Time:20150105T090000
329 DTEND;TZID=Eastern Standard Time:20150105T093000
330 UID:0123456789
331 CLASS:PUBLIC
332 PRIORITY:5
333 TRANSP:OPAQUE
334 STATUS:CONFIRMED
335 SEQUENCE:0
336 LOCATION;LANGUAGE=en-US:
337 END:VEVENT
338 END:VCALENDAR
339 EOF
340
341 cat >`mhpath new` <<'EOF'
342 From: [email protected]
343 To: [email protected]
344 Subject: test iCalendar reply
345 Content-Type: text/calendar; charset="UTF-8"
346 MIME-Version: 1.0
347
348 BEGIN:VCALENDAR
349 METHOD:REQUEST
350 PRODID:test-convert
351 VERSION:2.0
352 BEGIN:VTIMEZONE
353 TZID:Eastern Standard Time
354 BEGIN:STANDARD
355 DTSTART:16010101T020000
356 TZOFFSETFROM:-0400
357 TZOFFSETTO:-0500
358 RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=1SU;BYMONTH=11
359 END:STANDARD
360 BEGIN:DAYLIGHT
361 DTSTART:16010101T020000
362 TZOFFSETFROM:-0500
363 TZOFFSETTO:-0400
364 RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=2SU;BYMONTH=3
365 END:DAYLIGHT
366 END:VTIMEZONE
367 BEGIN:VEVENT
368 ORGANIZER;CN=Requester:MAILTO:[email protected]
369 ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN=Requestee1
370 :MAILTO:[email protected]
371 ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN=Requestee2
372 :MAILTO:[email protected]
373 ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN=Requestee3
374 :MAILTO:[email protected]
375 SUMMARY;LANGUAGE=en-US:test request
376 DTSTART;TZID=Eastern Standard Time:20150105T090000
377 DTEND;TZID=Eastern Standard Time:20150105T093000
378 UID:0123456789
379 CLASS:PUBLIC
380 PRIORITY:5
381 DTSTAMP:20150101T171600Z
382 TRANSP:OPAQUE
383 STATUS:CONFIRMED
384 SEQUENCE:0
385 LOCATION;LANGUAGE=en-US:
386 BEGIN:VALARM
387 ACTION:DISPLAY
388 DESCRIPTION:REMINDER
389 TRIGGER;RELATED=START:-PT15M
390 END:VALARM
391 END:VEVENT
392 END:VCALENDAR
393 EOF
394
395 actual="$MH_TEST_DIR/test-convert$$.actual"
396 repl -noformat \
397 -convertargs text/calendar '-reply accept -contenttype' -nowhatnowproc last
398 SIGNATURE=Recip mhbuild -auto - <`mhpath +`/draft | grep -v '^DTSTAMP:' >"$actual"
399 check "$actual" "$expected"
400
401
402 finish_test
403 exit $failed