]> diplodocus.org Git - nmh/blob - test/mhbuild/test-ext-params
Re-do length calculation for parameter output, and adapt test for new code.
[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 expected="$MH_TEST_DIR/$$.expected"
21
22 #
23 # Try out a draft with some 8-bit encoded parameters
24 #
25
26 cat > "$draft" <<EOF
27 To: Mr Test <mrtest@example.com>
28 cc:
29 Fcc: +outbox
30 ------
31 This is a test message
32 #image/jpeg {attachment; filename="tïny.jpg"} ${srcdir}/test/mhbuild/tiny.jpg
33 EOF
34
35 run_prog mhbuild "$draft"
36
37 cat > "$expected" <<EOF
38 To: Mr Test <mrtest@example.com>
39 cc:
40 Fcc: +outbox
41 MIME-Version: 1.0
42 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
43
44 ------- =_aaaaaaaaaa0
45 Content-Type: text/plain; charset="us-ascii"
46
47 This is a test message
48
49 ------- =_aaaaaaaaaa0
50 Content-Type: image/jpeg
51 Content-Disposition: attachment; filename*=UTF-8''t%C3%AFny.jpg
52 Content-Transfer-Encoding: base64
53
54 /9g=
55
56 ------- =_aaaaaaaaaa0--
57 EOF
58
59 check "$draft" "$expected"
60
61 #
62 # Try out a draft with some long parameters
63 #
64
65 cat > "$draft" <<EOF
66 To: Mr Test <mrtest@example.com>
67 cc:
68 Fcc: +outbox
69 ------
70 This is a test message
71 #image/jpeg {attachment; filename="This is an example of a rather long filename that is longer than would fit on a normal line.jpg"} \
72 ${srcdir}/test/mhbuild/tiny.jpg
73 EOF
74
75 run_prog mhbuild "$draft"
76
77 cat > "$expected" <<EOF
78 To: Mr Test <mrtest@example.com>
79 cc:
80 Fcc: +outbox
81 MIME-Version: 1.0
82 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
83
84 ------- =_aaaaaaaaaa0
85 Content-Type: text/plain; charset="us-ascii"
86
87 This is a test message
88
89 ------- =_aaaaaaaaaa0
90 Content-Type: image/jpeg
91 Content-Disposition: attachment;
92 filename*0="This is an example of a rather long filename that is lo";
93 filename*1="nger than would fit on a normal line.jpg"
94 Content-Transfer-Encoding: base64
95
96 /9g=
97
98 ------- =_aaaaaaaaaa0--
99 EOF
100
101 check "$draft" "$expected"
102
103 #
104 # Try out both!
105 #
106
107 cat > "$draft" <<EOF
108 To: Mr Test <mrtest@example.com>
109 cc:
110 Fcc: +outbox
111 ------
112 This is a test message
113 #image/jpeg {attachment; filename="This is an ëxample of a rather long filename that is longer than would fit on a normal line.jpg"} \
114 ${srcdir}/test/mhbuild/tiny.jpg
115 EOF
116
117 run_prog mhbuild "$draft"
118
119 cat > "$expected" <<EOF
120 To: Mr Test <mrtest@example.com>
121 cc:
122 Fcc: +outbox
123 MIME-Version: 1.0
124 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
125
126 ------- =_aaaaaaaaaa0
127 Content-Type: text/plain; charset="us-ascii"
128
129 This is a test message
130
131 ------- =_aaaaaaaaaa0
132 Content-Type: image/jpeg
133 Content-Disposition: attachment;
134 filename*0*=UTF-8''This%20is%20an%20%C3%ABxample%20of%20a%20rather;
135 filename*1=" long filename that is longer than would fit on a norma";
136 filename*2="l line.jpg"
137 Content-Transfer-Encoding: base64
138
139 /9g=
140
141 ------- =_aaaaaaaaaa0--
142 EOF
143
144 check "$draft" "$expected"
145
146 exit ${failed:-0}