File: test-convert

package info (click to toggle)
nmh 1.8-4
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 7,860 kB
  • sloc: ansic: 50,445; sh: 22,697; makefile: 1,138; lex: 740; perl: 509; yacc: 265
file content (403 lines) | stat: -rwxr-xr-x 9,187 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
#!/bin/sh
######################################################
#
# Test repl -convertarg
#
######################################################

set -e

if test -z "${MH_OBJ_DIR}"; then
    srcdir=`dirname $0`/../..
    MH_OBJ_DIR=`cd $srcdir && pwd`; export MH_OBJ_DIR
fi

. "${srcdir}/test/post/test-post-common.sh"

expected="$MH_TEST_DIR/test-convert$$.expected"
actual=`mhpath +`/draft

printf 'Local-Mailbox: recipient@example.com\n' >>"$MH"


#### Make sure that this works with 7-bit encoding.
LC_ALL=C; export LC_ALL


# check -convertarg with multiple parts and additional text in draft
start_test '-convertarg with multiple parts and additional text in draft'
cat >"$expected" <<'EOF'
From: recipient@example.com
To: sender@example.com
cc: 
Fcc: +outbox
Subject: Re: test
Comments: In-reply-to sender@example.com
   message dated "Thu, 11 Dec 2014 08:19:02 -0600."
MIME-Version: 1.0
Content-Type: text/plain; charset="US-ASCII"

> This is part 1.

> This is part 2.
EOF

cat >`mhpath new` <<'EOF'
From: sender@example.com
To: recipient@example.com
Subject: test
Date: Thu, 11 Dec 2014 08:19:02 -0600
Content-Type: multipart/mixed; boundary="_001_"
MIME-Version: 1.0

--_001_
Content-Type: text/plain

This is part 1.

--_001_
Content-Type: text/plain

This is part 2.

--_001_
Content-Type: text/enriched

This should not appear in the reply
because the content type isn't matched.

--_001_--
EOF

repl -noformat -convertarg text/plain '' -nowhatnowproc last
mhbuild -auto "$actual"
check "$actual" "$expected"


start_test "test ability to edit prior to encoding"
cat >"$expected" <<'EOF'
From: recipient@example.com
To: sender@example.com
cc: 
Fcc: +outbox
Subject: Re: test
Comments: In-reply-to sender@example.com
   message dated "Thu, 11 Dec 2014 08:19:02 -0600."
Nmh-check-text-encoding: unencoded
MIME-Version: 1.0
Content-Type: text/plain; charset="US-ASCII"

sender@example.com writes:

> This is a very, very, very, very, very, very, very, very, very, very, very, long line.
EOF

cat >`mhpath new` <<'EOF'
From: sender@example.com
To: recipient@example.com
Subject: test
Date: Thu, 11 Dec 2014 08:19:02 -0600
Content-Type: multipart/mixed; boundary="_001_"
MIME-Version: 1.0

--_001_
Content-Type: text/plain

This is a very, very, very, very, very, very, very, very, very, very, very, long line.

--_001_--
EOF

#### Just prefix the text with "> ".
cp "${MH}" "${MH}.new"
cat >>"${MH}.new" <<EOF
mhbuild-convert-text: sed 's/^\(.\)/> \1/; s/^$/>/;' <%F
EOF
repl -filter mhl.replywithoutbody -convertarg text/plain '' \
     -nowhatnowproc last
MH="${MH}.new" mhbuild "$actual"
check "$actual" "$expected"


# check that text is quoted-printable encoded due to long text line
# This tests the setting of reply_ct->c_reqencoding and
# (*text_plain_ct)->c_reqencoding in expand_pseudoheader().
start_test "encode text as quoted-printable due to long text line"
cat >"$expected" <<'EOF'
From: recipient@example.com
To: sender@example.com
cc: 
Fcc: +outbox
Subject: Re: test
Comments: In-reply-to sender@example.com
   message dated "Thu, 11 Dec 2014 08:19:02 -0600."
MIME-Version: 1.0
Content-Type: text/plain; charset="US-ASCII"
Content-Transfer-Encoding: quoted-printable

sender@example.com writes:

> This is a very, very, very, very, very, very, very, very, very, very, ve=
ry, long line.
EOF

repl -filter mhl.replywithoutbody -convertarg text/plain '' \
     -nowhatnowproc last
MH="${MH}.new" mhbuild -auto "$actual"
rm "${MH}.new"
check "$actual" "$expected"


#### Make sure that this works with 8-bit encoding.
finish_test
require_locale $en_locales


# check -convertarg with multiple parts, 7 bit
start_test '-convertarg with multiple parts, 7 bit'
cat >"$expected" <<'EOF'
From: recipient@example.com
To: sender@example.com
cc: 
Fcc: +outbox
Subject: Re: test
Comments: In-reply-to sender@example.com
   message dated "Thu, 11 Dec 2014 08:19:02 -0600."
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"

sender@example.com writes:

> This is part 1.

> This is part 2.
EOF

cat >`mhpath new` <<'EOF'
From: sender@example.com
To: recipient@example.com
Subject: test
Date: Thu, 11 Dec 2014 08:19:02 -0600
Content-Type: multipart/mixed; boundary="_001_"
MIME-Version: 1.0

--_001_
Content-Type: text/plain

This is part 1.

--_001_
Content-Type: text/plain; charset="UTF-8"

This is part 2.

--_001_--
EOF

repl -filter mhl.replywithoutbody -convertarg text/plain '' -nowhatnowproc last
mhbuild -auto "$actual"
check "$actual" "$expected"


# check -convertarg with multiple parts, 8 bit
start_test '-convertarg with multiple parts, 8 bit'
cat >"$expected" <<'EOF'
From: recipient@example.com
To: sender@example.com
cc: 
Fcc: +outbox
Subject: Re: test
Comments: In-reply-to sender@example.com
   message dated "Thu, 11 Dec 2014 08:19:02 -0600."
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 8bit

sender@example.com writes:

> This is part 1.

> This is §2, with a non-ASCII character.
EOF

cat >`mhpath new` <<'EOF'
From: sender@example.com
To: recipient@example.com
Subject: test
Date: Thu, 11 Dec 2014 08:19:02 -0600
Content-Type: multipart/mixed; boundary="_001_"
MIME-Version: 1.0

--_001_
Content-Type: text/plain

This is part 1.

--_001_
Content-Type: text/plain; charset="UTF-8"

This is §2, with a non-ASCII character.

--_001_--
EOF

repl -filter mhl.replywithoutbody -convertarg text/plain '' -nowhatnowproc last
mhbuild -auto "$actual"
check "$actual" "$expected"


# check message with text part in multipart/related
start_test 'check message with text part in multipart/related'
cat >"$expected" <<'EOF'
From: recipient@example.com
To: sender@example.com
cc: 
Fcc: +outbox
Subject: Re: test with text part in multipart/related
Comments: In-reply-to sender@example.com
   message dated "."
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"

sender@example.com writes:

> This is a test.
EOF

cat >`mhpath new` <<'EOF'
From: sender@example.com
To: recipient@example.com
Subject: test with text part in multipart/related
Content-Type: multipart/alternative; boundary="_001_"
MIME-Version: 1.0

--_001_
Content-Type: multipart/related; type="text/plain"; boundary="_002_"

--_002_
Content-Type: text/plain; charset="UTF-8"

This is a test.

--_002_--

--_001_--
EOF

repl -filter mhl.replywithoutbody -convertarg text/plain '' -nowhatnowproc last
mhbuild -auto "$actual"
check "$actual" "$expected"


# check reply to calendar request
start_test 'check reply to calendar request'
cat >"$expected" <<'EOF'
From: recipient@example.com
To: sender@example.com
cc: 
Fcc: +outbox
Subject: Re: test iCalendar reply
Comments: In-reply-to sender@example.com
   message dated "."
MIME-Version: 1.0
Content-Type: text/calendar; method="REPLY"; charset="UTF-8"

BEGIN:VCALENDAR
METHOD:REPLY
PRODID:nmh mhical v0.5
VERSION:2.0
BEGIN:VTIMEZONE
TZID:Eastern Standard Time
BEGIN:STANDARD
DTSTART:16010101T020000
TZOFFSETFROM:-0400
TZOFFSETTO:-0500
RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=1SU;BYMONTH=11
END:STANDARD
BEGIN:DAYLIGHT
DTSTART:16010101T020000
TZOFFSETFROM:-0500
TZOFFSETTO:-0400
RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=2SU;BYMONTH=3
END:DAYLIGHT
END:VTIMEZONE
BEGIN:VEVENT
ORGANIZER;CN=Requester:MAILTO:requester@example.com
ATTENDEE;PARTSTAT=ACCEPTED;CN=Recip:MAILTO:recipient@example.com
SUMMARY;LANGUAGE=en-US:Accepted: test request
DTSTART;TZID=Eastern Standard Time:20150105T090000
DTEND;TZID=Eastern Standard Time:20150105T093000
UID:0123456789
CLASS:PUBLIC
PRIORITY:5
TRANSP:OPAQUE
STATUS:CONFIRMED
SEQUENCE:0
LOCATION;LANGUAGE=en-US:
END:VEVENT
END:VCALENDAR
EOF

cat >`mhpath new` <<'EOF'
From: sender@example.com
To: recipient@example.com
Subject: test iCalendar reply
Content-Type: text/calendar; charset="UTF-8"
MIME-Version: 1.0

BEGIN:VCALENDAR
METHOD:REQUEST
PRODID:test-convert
VERSION:2.0
BEGIN:VTIMEZONE
TZID:Eastern Standard Time
BEGIN:STANDARD
DTSTART:16010101T020000
TZOFFSETFROM:-0400
TZOFFSETTO:-0500
RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=1SU;BYMONTH=11
END:STANDARD
BEGIN:DAYLIGHT
DTSTART:16010101T020000
TZOFFSETFROM:-0500
TZOFFSETTO:-0400
RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=2SU;BYMONTH=3
END:DAYLIGHT
END:VTIMEZONE
BEGIN:VEVENT
ORGANIZER;CN=Requester:MAILTO:requester@example.com
ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN=Requestee1
 :MAILTO:requestee1@example.com
ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN=Requestee2
 :MAILTO:requestee2@example.com
ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN=Requestee3
 :MAILTO:requestee3@example.com
SUMMARY;LANGUAGE=en-US:test request
DTSTART;TZID=Eastern Standard Time:20150105T090000
DTEND;TZID=Eastern Standard Time:20150105T093000
UID:0123456789
CLASS:PUBLIC
PRIORITY:5
DTSTAMP:20150101T171600Z
TRANSP:OPAQUE
STATUS:CONFIRMED
SEQUENCE:0
LOCATION;LANGUAGE=en-US:
BEGIN:VALARM
ACTION:DISPLAY
DESCRIPTION:REMINDER
TRIGGER;RELATED=START:-PT15M
END:VALARM
END:VEVENT
END:VCALENDAR
EOF

actual="$MH_TEST_DIR/test-convert$$.actual"
repl -noformat \
     -convertargs text/calendar '-reply accept -contenttype' -nowhatnowproc last
SIGNATURE=Recip mhbuild -auto - <`mhpath +`/draft | grep -v '^DTSTAMP:' >"$actual"
check "$actual" "$expected"


finish_test
exit $failed