]> diplodocus.org Git - nmh/blob - test/mhlist/test-ext-params
More tests for extended-parameter parsing.
[nmh] / test / mhlist / test-ext-params
1 #!/bin/sh
2 ######################################################
3 #
4 # Test mhlist with extended parameters (RFC 2231)
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 . "$MH_OBJ_DIR/test/common.sh"
16
17 setup_test
18
19 expected=$MH_TEST_DIR/$$.expected
20 actual=$MH_TEST_DIR/$$.actual
21 LC_ALL=en_US.UTF-8; export LC_ALL
22
23 #
24 # Write a message with some extended parameters
25 #
26
27 msgfile=`mhpath new`
28 cat > $msgfile <<EOF
29 To: recipient@example.com
30 From: sender@example.com
31 Subject: mhlist ext param test 1
32 MIME-Version: 1.0
33 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
34
35 ------- =_aaaaaaaaaa0
36 Content-Type: text/plain; charset=us-ascii;
37 name*=utf-8''This%20%C3%AFs%20the%20filename
38
39 This is a test
40
41 ------- =_aaaaaaaaaa0
42 Content-Type: image/jpeg;
43 name*0="This is an example of a very long filename. I wonder ";
44 name*1=if;
45 name*2=" this filename might be too long. It should not be. But";
46 name*3=" will it be?.jpg"
47 Content-Disposition: attachment;
48 filename*0="This is an example of a very long filename. I wonder ";
49 filename*1=if;
50 filename*2=" this filename might be too long. It should not be. But";
51 filename*3=" will it be?.jpg"
52 Content-Transfer-Encoding: base64
53
54 /9g=
55
56 ------- =_aaaaaaaaaa0--
57 EOF
58
59 # check to see if we decode parameters correctly.
60
61 run_test 'mhlist last -noheader -verbose -disposition' \
62 ' 11 multipart/mixed 637
63 boundary="----- =_aaaaaaaaaa0"
64 1 text/plain 15
65 charset="us-ascii"
66 name="This ïs the filename"
67 2 image/jpeg 2
68 name="This is an example of a very long filename. I wonder if this filename might be too long. It should not be. But will it be?.jpg"
69 disposition "attachment"
70 filename="This is an example of a very long filename. I wonder if this filename might be too long. It should not be. But will it be?.jpg"'
71
72 #
73 # Make some more complicated message parameters.
74 #
75
76 msgfile=`mhpath new`
77 cat > $msgfile <<EOF
78 To: recipient@example.com
79 From: sender@example.com
80 Subject: mhlist ext param test 2
81 MIME-Version: 1.0
82 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
83
84 ------- =_aaaaaaaaaa0
85 Content-Type: text/plain; charset=us-ascii;
86 name*=utf-8''This%20%C3%AFs%20the%20filename
87
88 This is a test
89
90 ------- =_aaaaaaaaaa0
91 Content-Type: image/jpeg; name*3=" will it be?.jpg";
92 longparam*5*=Sp%C4%B1n%CC%88al%20Tap!;
93 longparam*2=It; name*1=if;
94 longparam*3=" Might be our Long Lost Band";
95 longparam*0*=UTF-8'en'I%20Cannot%20Believe%20It;
96 name*0="This is an example of a very long filename. I wonder ";
97 longparam*4*=%20The%20%C3%96ne%20And%20Only%20;
98 name*2=" this filename might be too long. It should not be. But";
99 longparam*1=", it Looks Like "
100 Content-Transfer-Encoding: base64
101
102 /9g=
103
104 ------- =_aaaaaaaaaa0--
105 EOF
106
107 run_test 'mhlist last -noheader -verbose' \
108 ' 12 multipart/mixed 647
109 boundary="----- =_aaaaaaaaaa0"
110 1 text/plain 15
111 charset="us-ascii"
112 name="This ïs the filename"
113 2 image/jpeg 2
114 longparam="I Cannot Believe It, it Looks Like It Might be our Long Lost Band The Öne And Only Spın̈al Tap!"
115 name="This is an example of a very long filename. I wonder if this filename might be too long. It should not be. But will it be?.jpg"'
116
117 #
118 # Test out message/external-body types, and also make sure we will correctly
119 # decode a URL wrapped with RFC 2017 rules.
120 #
121
122 msgfile=`mhpath new`
123 cat > $msgfile <<EOF
124 To: recipient@example.com
125 From: sender@example.com
126 Subject: mhlist ext param test 3
127 MIME-Version: 1.0
128 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
129
130 ------- =_aaaaaaaaaa0
131 Content-Type: text/plain; charset=us-ascii;
132 name*=utf-8''This%20%C3%AFs%20the%20filename
133
134 This is a test
135
136 ------- =_aaaaaaaaaa0
137 Content-Type: message/external-body; access-type="url";
138 url*1="/that/should-be-wrapped/image.jpeg";
139 url*0="http://www.kremvax.ru/this/is/an/example/of/a/very/long/url"
140
141 Content-Type: image/jpeg
142 Content-Description: Test of a long URL
143 Content-Disposition: attachment; filename=image.jpeg
144
145 ------- =_aaaaaaaaaa0
146 Content-Type: message/external-body; access-type="url";
147 url*0="http://www.kremvax.ru/this/is/an/example/of/a/very/long/url
148 /that/should-be-wrapped/image.jpeg"
149
150 Content-Type: image/jpeg
151 Content-Description: Test of a long URL
152 Content-Disposition: attachment; filename=image.jpeg
153
154 ------- =_aaaaaaaaaa0--
155 EOF
156
157 run_test 'mhlist last -noheader -verbose -disposition' \
158 ' 13 multipart/mixed 775
159 boundary="----- =_aaaaaaaaaa0"
160 1 text/plain 15
161 charset="us-ascii"
162 name="This ïs the filename"
163 2 message/external-body 118
164 access-type="url"
165 url="http://www.kremvax.ru/this/is/an/example/of/a/very/long/url/that/should-be-wrapped/image.jpeg"
166 url="http://www.kremvax.ru/this/is/an/example/of/a/very/long/url/that/should-be-wrapped/image.jpeg"
167 access-type="url"
168 image/jpeg Test of a long URL
169 disposition "attachment"
170 filename="image.jpeg"
171 3 message/external-body 118
172 access-type="url"
173 url="http://www.kremvax.ru/this/is/an/example/of/a/very/long/url /that/should-be-wrapped/image.jpeg"
174 url="http://www.kremvax.ru/this/is/an/example/of/a/very/long/url/that/should-be-wrapped/image.jpeg"
175 access-type="url"
176 image/jpeg Test of a long URL
177 disposition "attachment"
178 filename="image.jpeg"'
179
180 exit $failed