Implement filter_prepend_home option.
[users/jgh/exim.git] / test / scripts / 0000-Basic / 0002
1 # Common string expansions
2 #
3 # This is the main string expansion test that tests those expansions that will
4 # be present in the basic Exim binary which we require in order to run these
5 # tests at all. Specialized expansion tests also exist for optional features
6 # in other test scripts.
7
8 exim -be
9
10 # These expansions can test variables in the configuration, but as there
11 # is no message being processed, there is no message-related data. But
12 # that of course gets tested in plenty of other places.
13
14 # Some fixed variables
15
16 exim_path: $exim_path
17 primary_hostname: $primary_hostname
18 primary_hostname: ${primary_hostname}
19 qualify_domain: $qualify_domain
20 bounce_return_size_limit: ${bounce_return_size_limit}
21 spool_directory: $spool_directory
22 unknown: ${unknown}
23 h_subject: $h_subject:(should be empty)
24 h_subject:$h_subject (should be empty)
25 header in curlies: ${header_subject:} (should fail)
26
27 # \$message_headers should be empty
28 message_headers: >$message_headers<
29
30 # Continuation
31 x\
32 y
33 x\
34              y
35
36 # Overlong names and overbig numbers
37
38 +$aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
39 +${aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}
40 +$11111111111111111111111111111111111
41 +${11111111111111111111111111111111111}
42
43 # Operators
44
45 addrss: ${address:local-part@dom.ain}
46 addrss: ${address:Exim Person <local-part@dom.ain> (that's me)}
47 domain: ${domain:local-part@dom.ain}
48 domain: ${domain:Exim Person <local-part@dom.ain> (that's me)}
49 escape: ${escape:B7·F2ò}
50 eval:   ${eval:1+1}
51 eval:   ${eval:1+2*3}
52 eval:   ${eval:(1+2)*3}
53 eval:   ${eval:3/2*4}
54 eval:   ${eval:3*4/2}
55 eval:   ${eval:42}
56 eval:   ${eval:}
57 eval:   ${eval:-2}
58 eval:   ${eval:-2 - -3}
59 eval:   ${eval:-2 - (-3)}
60 eval:   ${eval:-2 - (-3}
61 eval:   ${eval:-2 - -3)}
62 eval:   ${eval:-2 --3}
63 eval:   ${eval:-2 -+3}
64 eval:   ${eval:-2 -+-3}
65 eval:   ${eval:(2*(1+1))/2 + 40K}
66 eval:   ${eval:077}
67 eval:   ${eval:08}
68 eval10: ${eval10:077}
69 eval10: ${eval10:08}
70 expand: \$primary_hostname ${expand:\$primary_hostname}
71 hash:   ${hash_3:monty} ${hash_5:monty} ${hash_4_62:monty python}
72 hash:   ${hash_3:abc}X ${hash_3:ab}X ${hash_3:a}X ${hash_3:}X
73 hex2b64:${hex2b64:12345678}
74 hex2b64:${hex2b64:abcdef}
75 hex2b64:${hex2b64:ABCDEF}
76 hex2b64:${hex2b64:1a2b3c4d5e6f}
77 hex2b64:${hex2b64:1a2b3c4d5e6}
78 hex2b64:${hex2b64:1a2b3c4d5e6g}
79 hex2b64:${hex2b64:${md5:the quick brown fox}}
80 hex2b64:${hex2b64:${sha1:the quick brown fox}}
81
82 The base62 operator is actually a base36 operator in the Darwin and Cygwin
83 environments. Write cunning tests that produce the same output in both cases,
84 while doing a reasonable check.
85
86 base62:  ${if or {\
87                  {eq {${base62:12345}}{0003D7}}\
88                  {eq {${base62:12345}}{0009IX}}\
89                  }{OK}{NOT OK}} 
90 base62d: ${if or {\
91                  {eq {${base62d:0003D7}}{12345}}\
92                  {eq {${base62d:0009IX}}{12345}}\
93                  }{OK}{NOT OK}} 
94 base62d: ${if or {\
95                  {eq {${base62d:3D7}}{12345}}\
96                  {eq {${base62d:9IX}}{12345}}\
97                  }{OK}{NOT OK}} 
98 base62 error: ${base62:12345x}
99 base62d error:${base62d:0003D7.}
100
101 hmac:   ${hmac{md5}{somesecret}{mail.example.com 2002-10-17 11:30:59}}
102 hmac:   ${hmac{sha1}{somesecret}{mail.example.com 2002-10-17 11:30:59}}
103 md5:    ${md5:the quick brown fox jumps over the lazy dog}
104 sha1:   ${sha1:}
105 sha1:   ${sha1:abc}
106 mask:   ${mask:192.168.10.206/28}
107 mask:   ${mask:192.168.10.206/32}
108 mask:   ${mask:192.168.10.206/33}
109 mask:   ${mask:192.168.10.206/0}
110 mask:   ${mask:192.168.10.206}
111 mask:   ${mask:a.b.c.d}
112 nhash:  ${nhash_24:monty} ${nhash_8_63:monty python}
113 lc/uc:  ${lc:The Quick} ${uc: Brown Fox}
114 length: ${length_10:The quick brown fox} ${l_10:abc}
115 lclpt:  ${local_part:local-part@dom.ain}
116 lclpt:  ${local_part:Exim Person <local-part@dom.ain> (that's me)}
117 quote:  ${quote:aZ09_.-Q} ${quote:ab*cd} ${quote:ab\cd"ef}
118 quote:  ${quote:nl(\n)}
119 quote:  ${quote:cr(\r)}
120 quote:  ${quote:tab(\t)}
121 quote:  ${quote:xff(\xff)}
122 quote:  Empty>${quote:}<
123 quote_local_part: ${quote_local_part:abcd}
124 quote_local_part: ${quote_local_part:O'Reilly}
125 quote_local_part: ${quote_local_part:a space}
126 quote_local_part: ${quote_local_part:.something}
127 quote_local_part: ${quote_local_part:something.}
128 quote_local_part: ${quote_local_part:joe.bloggs}
129 quote_local_part: ${quote_local_part:a!b}
130 quote_local_part: ${quote_local_part:x@y}
131 quote_local_part: ${quote_local_part:ab*cd}
132 quote_local_part: ${quote_local_part:x:y}
133 quote_local_part: ${quote_local_part:ab\cd"ef}
134 quote_local_part: ${quote_local_part:}
135 rxquote:${rxquote:aZ09_,-Q} ${rxquote:ab*cd} ${rxquote:ab\cd"ef}
136 substr: ${substr_3_2:rhubarb} ${s_-5_2:1234567} ${s_-5_2:12} ${s_-3_2:12}
137 substr: ${s_3:rhubarb} ${s_-2:rhubarb}
138 substr: ${s_1:}
139 substr: ${substr_10:abc}
140 str2b64:${str2b64:abcd}
141 str2b64:${str2b64:The quick brown \n fox}
142 strlen: ${strlen:}
143 strlen: ${strlen:a}
144 strlen: ${strlen:abcdefgh}
145 time_eval:     ${time_eval:10s}
146 time_eval:     ${time_eval:2h}
147 time_eval:     ${time_eval:1d5m}
148 time_eval:     ${time_eval:1w2d3h4m5s}
149 time_eval:     ${time_eval:14}
150 time_eval:     ${time_eval:rhubarb}
151 time_interval: ${time_interval:0}
152 time_interval: ${time_interval:44}
153 time_interval: ${time_interval:999999}
154 time_interval: ${time_interval:-1}
155 time_interval: ${time_interval:rhubarb}
156
157 # stat is a bit tricky, but some of the fields of the aux-var directory
158 # should be the same on all systems
159
160 stat:   ${extract{mode}{${stat:DIR/aux-var}}}
161 stat:   ${extract{smode}{${stat:DIR/aux-var}}}
162 stat:   ${stat:/a/non/existent/file}
163
164 # "Operators" that have expanded arguments
165
166 hash:   ${hash{3}{monty}} ${hash{5}{monty}} ${hash{4}{62}{monty python}}
167 hash:   ${hash{3}{abc}}X ${hash{3}{ab}}X ${hash{3}{a}}X ${hash{3}{}}X
168 nhash:  ${nhash{24}{monty}} ${nhash{8}{63}{monty python}}
169 length: ${length{10}{The quick brown fox}} ${length{10}{abc}}
170 substr: ${substr{3}{2}{rhubarb}} ${substr{-5}{2}{1234567}} ${substr{-5}{2}{12}} ${substr{-3}{2}{12}}
171 substr: ${substr{${if eq{1}{1}{-8}}}{${if eq{1}{0}{25}{1}}}{abcde}}
172
173 # Error forms
174
175 ${hash{one}}
176 ${hash{nonnumber}{abcd}}
177 ${hash{3}{2}{4}{abcd}}
178 ${substr{-3}{-2}{abcd}}
179
180 # Skipped operators
181
182 addrss: ${if eq {1}{2}{${address:invalid}}{NO}}
183 domain: ${if eq {1}{2}{${domain:invalid}}{NO}}
184 escape: ${if eq {1}{2}{${escape:invalid}}{NO}}
185 expand: ${if eq {1}{2}{\$primary_hostname ${expand:\$invalid}}{NO}}
186 hash:   ${if eq {1}{2}{${hash_3:invalid}}{NO}}
187 md5:    ${if eq {1}{2}{${md5:invalid}}{NO}}
188 mask:   ${if eq {1}{2}{${mask:invalid}}{NO}}
189
190 # Conditions
191
192 2=2:    ${if ={2}{2}{y}{n}}
193 2==2:   ${if =={2}{2}{y}{n}}
194 3=2:    ${if ={3}{2}{y}{n}}
195 2==3:   ${if =={2}{3}{y}{n}}
196 !2=2:   ${if !={2}{2}{y}{n}}
197 !2==2:  ${if !=={2}{2}{y}{n}}
198 !3=2:   ${if !={3}{2}{y}{n}}
199 !2==3:  ${if !=={2}{3}{y}{n}}
200 2>3:    ${if >{2}{3}{y}{n}}
201 3>3:    ${if >{3}{3}{y}{n}}
202 4>3:    ${if >{4}{3}{y}{n}}
203 2>=3:   ${if >={2}{3}{y}{n}}
204 3>=3:   ${if >={3}{3}{y}{n}}
205 4>=3:   ${if >={4}{3}{y}{n}}
206 2<3:    ${if <{2}{3}{y}{n}}
207 3<3:    ${if <{3}{3}{y}{n}}
208 4<3:    ${if <{4}{3}{y}{n}}
209 2<=3:   ${if <={2}{3}{y}{n}}
210 3<=3:   ${if <={3}{3}{y}{n}}
211 4<=3:   ${if <={4}{3}{y}{n}}
212 5<=3:   ${if <={ 5 } { 3 } {y}{n}}
213
214 5>3k:   ${if >{5 } {3k }{y}{n}}
215 5>3m:   ${if >{5 } {3m }{y}{n}}
216 5>3z:   ${if >{5 } {3z }{y}{n}}
217 5>a:    ${if >{ 5 } {a}{y}{n}}
218
219 def:y   ${if def:tod_log{y}{n}}
220 def:n   ${if def:host{y}{n}}
221 def:f   ${if def:post{y}{n}}
222 def:h_f ${if def:h_xxx {y}{n}}
223 def:h_f ${if def:h_xxx:{y}{n}}
224 def:d:  ${if def:tod_log:{y}{n}}
225
226 exists: ${if exists{/etc/passwd}{y}{n}}
227 exists: ${if exists{/doesnt}{y}{n}}
228
229 eq:     ${if eq{abc}{abc}{y}{n}}
230 eq:     ${if eq{abc}{xyz}{y}{n}}
231 !eq:    ${if !eq{abc}{abc}{y}{n}}
232 !eq:    ${if !eq{abc}{xyz}{y}{n}}
233
234 eqi:    ${if eqi{abc}{abc}{y}{n}}
235 eqi:    ${if eqi{abc}{ABC}{y}{n}}
236 eqi:    ${if eqi{abc}{xyz}{y}{n}}
237 !eqi:   ${if !eqi{abc}{abc}{y}{n}}
238 !eqi:   ${if !eqi{abc}{aBc}{y}{n}}
239 !eqi:   ${if !eqi{abc}{xyz}{y}{n}}
240
241 lt:     ${if lt{ABC}{abc}{y}{n}}
242 lti:    ${if lti{ABC}{abc}{y}{n}}
243 le:     ${if le{ABC}{abc}{y}{n}}
244 lei:    ${if lei{ABC}{abc}{y}{n}}
245 gt:     ${if gt{ABC}{abc}{y}{n}}
246 gti:    ${if gti{ABC}{abc}{y}{n}}
247 ge:     ${if ge{ABC}{abc}{y}{n}}
248 gei:    ${if gei{ABC}{abc}{y}{n}}
249
250 isip:   ${if isip {1.2.3.4}{y}{n}}  1.2.3.4
251 isip4:  ${if isip4{1.2.3.4}{y}{n}}  1.2.3.4
252 isip6:  ${if isip6{1.2.3.4}{y}{n}}  1.2.3.4
253 isip:   ${if isip {1:2:3:4}{y}{n}}  1:2:3:4
254 isip4:  ${if isip4{1:2:3:4}{y}{n}}  1:2:3:4
255 isip6:  ${if isip6{1:2:3:4}{y}{n}}  1:2:3:4
256 isip:   ${if isip {::1}{y}{n}}      ::1
257 isip4:  ${if isip4{::1}{y}{n}}      ::1
258 isip6:  ${if isip6{::1}{y}{n}}      ::1
259 isip:   ${if isip {fe80::a00:20ff:fe86:a061}{y}{n}}  fe80::a00:20ff:fe86:a061
260 isip4:  ${if isip4{fe80::a00:20ff:fe86:a061}{y}{n}}  fe80::a00:20ff:fe86:a061
261 isip6:  ${if isip6{fe80::a00:20ff:fe86:a061}{y}{n}}  fe80::a00:20ff:fe86:a061
262 isip:   ${if isip {rhubarb}{y}{n}}  rhubarb
263 isip4:  ${if isip4{rhubarb}{y}{n}}  rhubarb
264 isip6:  ${if isip6{rhubarb}{y}{n}}  rhubarb
265
266 match:  ${if match{abcd}{\N^([ab]+)(\w+)$\N}{$2$1}fail}
267 match:  ${if match{abcd}{^\N([ab]+)(\w+)$\N}{$2$1}fail}
268 match:  ${if match{abcd}{^([ab]+)(\\w+)\$}{$2$1}fail}
269 match:  ${if match{wxyz}{^([ab]+)(\\w+)\$}{$2$1}fail}
270 match:  ${if match{abcd}{^([ab]+)(\\w+)\$}{$2[${if match{xyz}{(.*)}{$1}fail}]$1}fail}
271
272 match_domain:    ${if match_domain{a.b.c}{x.y.z:a.b.c:p.q.r}{yes}{no}}
273 match_domain:    ${if match_domain{a.b.c}{x.y.z:p.q.r}{yes}{no}}
274 match_domain:    ${if match_domain{5.aa.bb}{+dlist}{yes}{no}}
275 match_domain:    ${if match_domain{xxxyz}{+dlist}{yes}{no}}
276 match_domain:    ${if match_domain{xyz}{+dlist}{yes}{no}}
277
278 ${if match{x@zz.aa.bb}{^(.*)} \
279   { \
280   >$1< \ 
281   ${if match_domain{${domain:$1}}{+dlist}{[$1]}} \
282   >$1< \
283   } \
284   { CAN'T HAPPEN}} 
285
286 ${if match{x@xxxabc}{^(.*)} \
287   { \
288   >$1< \ 
289   ${if match_domain{${domain:$1}}{^\Nxxx(.*)\N}{[$1]}} \
290   >$1< \
291   } \
292   { CAN'T HAPPEN}} 
293
294 match_address:   ${if match_address{x@y.z}{p@q:*@y.z}{yes}{no}}
295 match_address:   ${if match_address{x@y.z}{p@q:x@*.z}{yes}{no}}
296
297 match_local_part:${if match_local_part{jo}{jack:jill:jo:john}{yes}{no}}
298 match_local_part:${if match_local_part{jo}{\N^\w\N}{yes}{no}}
299
300 match_ip:        01 ${if match_ip{1.2.3.4}{4.5.6.7:1.2.3.4}}
301 match_ip:        02 ${if match_ip{1.2.3.4}{4.5.6.7:1.2.3.6}}
302 match_ip:        03 ${if match_ip{1.2.3.4}{4.5.6.7:1.2.3.6/24}}
303 match_ip:        04 ${if match_ip{1.2.3.4}{4.5.6.7:1.2.3.6:*}}
304 match_ip:        05 ${if match_ip{1.2.3.4}{4.5.6.7:1.2.3.6:name}}
305 match_ip:        06 ${if match_ip{1.2.3.4}{:4.5.6.7}}
306 match_ip:        07 ${if match_ip{}{:4.5.6.7}}
307 match_ip:        08 ${if match_ip{V4NET.11.12.13}{+hlist}}
308 match_ip:        09 ${if match_ip{V4NET.11.12.14}{+hlist}}
309 match_ip:        10 ${if match_ip{192.168.3.4}{+hlist}}
310 match_ip:        11 ${if match_ip{somename}{+hlist}}
311 match_ip:        12 ${if match_ip{1.2.3.4}{lsearch;DIR/aux-fixed/0002.matchip}}
312 match_ip:        13 ${if match_ip{1.2.3.4}{net-lsearch;DIR/aux-fixed/0002.matchip}}
313 match_ip:        14 ${if match_ip{5.6.7.8}{net24-lsearch;DIR/aux-fixed/0002.matchip}}
314
315 queue_running:  ${if queue_running{y}{n}}
316 first_delivery: ${if first_delivery{y}{n}}
317
318 queue_running after or: ${if or{{eq {0}{0}}{queue_running}}{y}{n}}
319 first_delivery after or: ${if or{{eq {0}{0}}{first_delivery}}{y}{n}}
320
321 # Default values for both if strings
322
323 \${if eq{1}{1}}  >${if eq{1}{1}}<
324 \${if eq{1}{2}}  >${if eq{1}{2}}<
325
326 # Lookups: DIR is the testing directory. In this test we can only use the
327 # lookups that are required in all cases.
328
329 ${lookup{postmaster}lsearch{DIR/aux-fixed/0002.aliases}{$value}fail}
330
331 ${lookup{x@y}lsearch*@{DIR/aux-fixed/0002.starat}{$value}fail}
332 ${lookup{x@z}lsearch*{DIR/aux-fixed/0002.starat}{$value}fail}
333 ${lookup{x@z}lsearch*@{DIR/aux-fixed/0002.starat}{$value}fail}
334 ${lookup{x@w}lsearch*@{DIR/aux-fixed/0002.starat}{$value}fail}
335
336 ${lookup{a.b.c.d}partial-lsearch{DIR/aux-fixed/0002.domains}{$value}fail}
337 ${lookup{x.y.z}partial-lsearch{DIR/aux-fixed/0002.domains}{$value}{failed x.y.z}}
338 ${lookup{p.q}partial-lsearch{DIR/aux-fixed/0002.domains}{$value}fail}
339 ${lookup{o.p.q}partial-lsearch{DIR/aux-fixed/0002.domains}{$value}fail}
340 ${lookup{m.n.o.p.q}partial-lsearch{DIR/aux-fixed/0002.domains}{$value}fail}
341 ${lookup{x.y.z}partial1-lsearch{DIR/aux-fixed/0002.domains}{$value}fail}
342 ${lookup{x.y.z}partial0-lsearch{DIR/aux-fixed/0002.domains}{$value}fail}
343
344 q1:  ${lookup{abc}lsearch{DIR/aux-fixed/0002.quoted}}
345 q2:  ${lookup{xyz}lsearch{DIR/aux-fixed/0002.quoted}}
346 q3:  ${lookup{pqr}lsearch{DIR/aux-fixed/0002.quoted}}
347 q4:  ${lookup{a:b}lsearch{DIR/aux-fixed/0002.quoted}}
348 q5:  ${lookup{"quoted"}lsearch{DIR/aux-fixed/0002.quoted}}
349 q6:  ${lookup{white space}lsearch{DIR/aux-fixed/0002.quoted}}
350 q7:  ${lookup{b\\s}lsearch{DIR/aux-fixed/0002.quoted}}
351
352 abc:   ${lookup{abc}wildlsearch{DIR/aux-var/0002.wild}}
353 a.b.c: ${lookup{a.b.c}wildlsearch{DIR/aux-var/0002.wild}}
354 ab.c:  ${lookup{ab.c}wildlsearch{DIR/aux-var/0002.wild}}
355 xyz:   ${lookup{xyz}wildlsearch{DIR/aux-var/0002.wild}}
356 Xyz:   ${lookup{Xyz}wildlsearch{DIR/aux-var/0002.wild}}
357 Zyz:   ${lookup{Zyz}wildlsearch{DIR/aux-var/0002.wild}}
358 a b:   ${lookup{a b}wildlsearch{DIR/aux-var/0002.wild}}
359 a  b:  ${lookup{a  b}wildlsearch{DIR/aux-var/0002.wild}}
360 a:b:   ${lookup{a:b}wildlsearch{DIR/aux-var/0002.wild}}
361 a.b:   ${lookup{a.b}wildlsearch{DIR/aux-var/0002.wild}}
362 a..b:  ${lookup{a..b}wildlsearch{DIR/aux-var/0002.wild}}
363 a9b:   ${lookup{a9b}wildlsearch{DIR/aux-var/0002.wild}}
364 a99b:  ${lookup{a99b}wildlsearch{DIR/aux-var/0002.wild}}
365
366 # Should give the same results as above because expansion does nothing
367
368 abc:   ${lookup{abc}nwildlsearch{DIR/aux-var/0002.wild}}
369 a.b.c: ${lookup{a.b.c}nwildlsearch{DIR/aux-var/0002.wild}}
370 ab.c:  ${lookup{ab.c}nwildlsearch{DIR/aux-var/0002.wild}}
371 xyz:   ${lookup{xyz}nwildlsearch{DIR/aux-var/0002.wild}}
372 Xyz:   ${lookup{Xyz}nwildlsearch{DIR/aux-var/0002.wild}}
373 Zyz:   ${lookup{Zyz}nwildlsearch{DIR/aux-var/0002.wild}}
374 a b:   ${lookup{a b}nwildlsearch{DIR/aux-var/0002.wild}}
375 a  b:  ${lookup{a  b}nwildlsearch{DIR/aux-var/0002.wild}}
376 a:b:   ${lookup{a:b}nwildlsearch{DIR/aux-var/0002.wild}}
377
378 # Should fail because of no expansion
379
380 a.b:   ${lookup{a.b}nwildlsearch{DIR/aux-var/0002.wild}{$value}{NO}}
381 a..b:  ${lookup{a..b}nwildlsearch{DIR/aux-var/0002.wild}{$value}{NO}}
382 a9b:   ${lookup{a9b}nwildlsearch{DIR/aux-var/0002.wild}{$value}{NO}}
383 a99b:  ${lookup{a99b}nwildlsearch{DIR/aux-var/0002.wild}{$value}{NO}}
384
385 # But these should succeed
386
387 a\\:b:  ${lookup{a\\:b}nwildlsearch{DIR/aux-var/0002.wild}}
388 a\\:Xb: ${lookup{a\\:Xb}nwildlsearch{DIR/aux-var/0002.wild}}
389
390 # IP address (CIDR) lookups
391
392 1.2.3.4:      ${lookup{1.2.3.4}iplsearch{DIR/aux-fixed/0002.iplsearch}}
393 1.2.3.5:      ${lookup{1.2.3.5}iplsearch{DIR/aux-fixed/0002.iplsearch}}
394 1.2.3.5:      ${lookup{1.2.3.5}iplsearch*{DIR/aux-fixed/0002.iplsearch}}
395 abcd::cdab:   ${lookup{abcd::cdab}iplsearch{DIR/aux-fixed/0002.iplsearch}}
396 192.168.1.2:  ${lookup{192.168.1.2}iplsearch{DIR/aux-fixed/0002.iplsearch}}
397 192.168.5.6:  ${lookup{192.168.5.6}iplsearch{DIR/aux-fixed/0002.iplsearch}}
398 abcd:abcd::   ${lookup{abcd:abcd::}iplsearch{DIR/aux-fixed/0002.iplsearch}}
399 abcd:abcd:1:: ${lookup{abcd:abcd:1::}iplsearch{DIR/aux-fixed/0002.iplsearch}}
400 abcd:abcd::3  ${lookup{abcd:abcd::3}iplsearch{DIR/aux-fixed/0002.iplsearch}}
401 rhubarb       ${lookup{rhubarb}iplsearch{DIR/aux-fixed/0002.iplsearch}}
402
403
404 # Nested Lookups - style 1
405
406 ${lookup{${lookup{key1}lsearch{DIR/aux-fixed/0002.rec}{$value}{key1f}}}lsearch{DIR/aux-fixed/0002.rec}{$value}fail}
407 ${lookup{${lookup{key3}lsearch{DIR/aux-fixed/0002.rec}{$value}{key1f}}}lsearch{DIR/aux-fixed/0002.rec}{$value}fail}
408
409 # Nested Lookups - style 2
410
411 ${lookup{key1}lsearch{DIR/aux-fixed/0002.rec}{${lookup{$value}lsearch{DIR/aux-fixed/0002.rec}{$value}{failed for $value}}}{failed for key1}}
412 ${lookup{key3}lsearch{DIR/aux-fixed/0002.rec}{${lookup{$value}lsearch{DIR/aux-fixed/0002.rec}{$value}{failed for $value}}}{failed for key1}}
413
414 # Other nesting tests
415
416 ${lookup{one}lsearch{DIR/aux-fixed/0002.alias1}{$value${lookup{one}lsearch{DIR/aux-fixed/0002.alias2}{,$value}}}{${lookup{one}lsearch{DIR/aux-fixed/0002.alias2}{$value}fail}}}
417 ${lookup{two}lsearch{DIR/aux-fixed/0002.alias1}{$value${lookup{two}lsearch{DIR/aux-fixed/0002.alias2}{,$value}}}{${lookup{two}lsearch{DIR/aux-fixed/0002.alias2}{$value}fail}}}
418 ${lookup{both}lsearch{DIR/aux-fixed/0002.alias1}{$value${lookup{both}lsearch{DIR/aux-fixed/0002.alias2}{,$value}}}{${lookup{both}lsearch{DIR/aux-fixed/0002.alias2}{$value}fail}}}
419 ${lookup{neither}lsearch{DIR/aux-fixed/0002.alias1}{$value${lookup{neither}lsearch{DIR/aux-fixed/0002.alias2}{,$value}}}{${lookup{neither}lsearch{DIR/aux-fixed/0002.alias2}{$value}fail}}}
420
421 # Lookup quotes for standardly expected lookups
422
423 lsearch ${quote_lsearch: !@#\$%^&*()_-+=|\\~`1234567890\{[\}]qwertyuiop:;"'asdfghjkl<,>.?/zxcvbnm}
424 xxx     ${quote_xxx: !@#\$%^&*()_-+=|\\~`1234567890\{[\}]qwertyuiop:;"'asdfghjkl<,>.?/zxcvbnm}
425
426 # Extract
427
428 ${extract{B}{A=1 B=2 C=3}}
429 ${extract{ B }{A=1 B=2 C=3}{$value}{NOT FOUND}}
430 ${extract{2}{:}{1:2:3}}
431 ${extract{ 2 }{:}{1:2:3}{$value}{NOT FOUND}}
432 Empty:<${extract{D}{A=1 B=2 C=3}}>
433 Empty:<${extract{4}{:}{1:2:3}}>
434 ${extract{C}{A=1 B=2 C=3}{<$value>}}
435 ${extract{3}{:}{1:2:3}{<$value>}}
436 Empty:<${extract{Z}{A=1 B=2 C=3}{<$value>}}>
437 Empty:<${extract{4}{:}{1:2:3}{<$value>}}>
438 ${extract{Z}{A=1 B=2 C=3}{<$value>}{no Z}}
439 ${extract{4}{:}{1:2:3}{<$value>}{no 4}}
440 ${extract{Z}{A=1 B=2 C=3}{<$value>}fail}
441 ${extract{4}{:}{1:2:3}{<$value>}fail}
442 ${extract{K4}{${sg{1=A 4=D 3=C}{(\\d+)=}{K\$1=}}}}
443 ${extract{0}{:}{a:b:c:d:e}{$value}{FAIL}}
444 ${extract{1}{:}{a:b:c:d:e}{$value}{FAIL}}
445 ${extract{-1}{:}{a:b:c:d:e}{$value}{FAIL}}
446 ${extract{-5}{:}{a:b:c:d:e}{$value}{FAIL}}
447 ${extract{-6}{:}{a:b:c:d:e}{$value}{FAIL}}
448 ${extract{-3}{:,}{a,,b::c}}
449 ${extract{2}{:,}{a,,b::c}}
450 ${extract{3}{:,}{a,,b::c}}
451 ${extract{a-b}{X = "one two" a-b "three four" 5=99}}
452 ${extract{}{X=3}}
453 ${extract{ }{X=3}}
454 ${extract{ 2 }{ }{a b c}}
455
456 # Translation
457
458 abcdea aaa xyz ${tr{abcdea}{aaa}{xyz}}
459 abcdea a   z   ${tr{abcdea}{a}{z}}
460 abcdea a       ${tr{abcdea}{a}{}}
461 abcdea abc z   ${tr{abcdea}{abc}{z}}
462
463 # RFC 2047
464
465 abcd      ${rfc2047:abcd}
466 <:abcd:>  ${rfc2047:<:abcd:>}
467 <:ab cd:> ${rfc2047:<:ab cd:>}
468 Long:     ${rfc2047: here we go: a string that is going to be encoded: it will go over the 75-char limit}
469 Long:     ${rfc2047: here we go: a string that is going to be encoded: it will go over the 75-char limit by a long way; in fact this one will go over the 150 character limit}
470
471
472 # UTF-8
473
474 abcd      ${from_utf8:abcd}
475 aÀÿd      ${from_utf8:aÃ\80ÿd}
476 toobig    ${from_utf8:aĀd}
477
478 # Substitution
479
480 \${sg{abcdefabcdef}{abc}{xyz}}          =${sg{abcdefabcdef}{abc}{xyz}}
481 \${sg{ab:xy::z}{:}{::}}                 =${sg{ab:xy::z}{:}{::}}
482 \${sg{abcdefabcdef}{(..)[^c]}{>\$1<}}    =${sg{abcdefabcdef}{(..)[^c]}{>$1<}}
483 \${sg{abcdefabcdef}{(..)[^c]}{>\\\$1<}}   =${sg{abcdefabcdef}{(..)[^c]}{>\$1<}}
484 \${sg{abcdefabcdef}{(..)[^c]}{>\\N\$1\\N<}}=${sg{abcdefabcdef}{(..)[^c]}{>\N$1\N<}}
485 \${sg{abbab}{a*}{+}}                    =${sg{abbab}{a*}{+}}
486
487 # File insertion
488
489 ${readfile}
490 ${readfile{DIR/aux-fixed/0002.readfile}}
491 ${readfile{DIR/aux-fixed/0002.readfile}{}}
492 ${readfile{DIR/aux-fixed/0002.readfile}{:}}
493 ${readfile{DIR/aux-fixed/0002.readfile}{ - }}
494 ${readfile{/non/exist/file}}
495 ${if exists{/non/exist/file}{${readfile{/non/exist/file}}}{non-exist}}
496 >${readfile{DIR/aux-fixed/0002.readfile}{!}}\
497     <
498
499 # Calling a command
500
501 ${run{DIR/aux-fixed/0002.runfile 0}}
502 RC=$runrc
503 ${run{DIR/aux-fixed/0002.runfile 0}{1}{2}}
504 RC=$runrc
505 ${run{DIR/aux-fixed/0002.runfile 0}{$value}{2}}
506 RC=$runrc
507 ${run{DIR/aux-fixed/0002.runfile 1}{$value}{2}}
508 RC=$runrc
509 ${run{DIR/aux-fixed/0002.runfile 1}{$value}{$value}}
510 RC=$runrc
511 ${run{DIR/test-nonexist}{Y}{N}}
512 RC=$runrc
513 >>${run{DIR/bin/iefbr14}}<<
514 RC=$runrc
515 ${if eq{1}{2}{${run{/non/exist}}}{1!=2}}
516 RC=$runrc
517
518 # PRVS
519
520 ${prvs{userx@test.ex}{secret}}
521 ${prvs{userx@test.ex}{secret}{1}}
522 ${prvs{userx@test.ex}{secret}{8}}
523
524 # Syntax errors
525
526 ${prvs{userx@test.ex}{secret}{12}}
527 ${prvs{userx@test.ex}{secret}{rhubarb}}
528 ${prvs{userx@test.ex}{secret}{}}
529
530 # Correct checks; can't put explicit addresses in the tests, because they
531 # will change over time. 
532
533 ${prvscheck{${prvs{userx@test.ex}{secret}}}{secret}}
534 result=$prvscheck_result
535
536 ${prvscheck{${prvs{userx@test.ex}{secret}{1}}}{secret}\
537 {>$prvscheck_result< >$prvscheck_address< >$prvscheck_keynum<}}
538 result=$prvscheck_result
539
540 ${prvscheck{${prvs{userx@test.ex}{secret}{8}}}{secret}{}}
541 result=$prvscheck_result
542
543 # Incorrect secret
544
545 ${prvscheck{${prvs{userx@test.ex}{secret}}}{socrot}}
546 result=$prvscheck_result
547
548 ${prvscheck{${prvs{userx@test.ex}{secret}}}{socrot}{$prvscheck_keynum}}
549 result=$prvscheck_result
550
551 # Non-prvs address
552
553 >>${prvscheck{userx@test.ex}{secret}}<<
554 result=$prvscheck_result
555
556 # Syntax errors
557
558 ${tod_log
559 ${tod_log+6
560 ${expand:abcd
561 ${expand:abcd${tod_log}
562 ${hmac{xxx}{a}{b}}
563 ${if and {xyz}{a}{b}}
564 ${if and {{xya}}{a}{b}}
565 ${if and {{${lookup{x}lsearch{/a/b}}}}{a}{b}}
566 ${if eq {$h_xyz}{1}{y}{n}}
567 ${if or {eq {}{}{yes}{no}}
568 ${if or {{eq {}{}{yes}{no}}
569 ${if or {{eq {}{}}{yes}{no}}
570 ${substr_1_:12345}
571 ${substr__3:12345}
572
573 # Miscellaneous (for bug fixes, etc)
574
575 ${if ={1}{1} {true}{${if ={1}{1} {true}{${if ={1}{1}{true}fail}}}}}
576
577 ****
578 # Test "escape" with print_topbitchars
579 exim -be -DPTBC=print_topbitchars
580 escape: ${escape:B7·F2ò}
581 ****
582 # Checkout expansion debugging
583 exim -d-all+expand -be
584 primary_hostname: $primary_hostname
585 match:  ${if match{abcd}{\N^([ab]+)(\w+)$\N}{$2$1}fail}
586 match:  ${if match{wxyz}{\N^([ab]+)(\w+)$\N}{$2$1}fail}
587 ${if eq {1}{1}{yes}{${lookup{xx}lsearch{/non/exist}}}}
588 match_address:   ${if match_address{a.b.c}{a.b.c}{yes}{no}}
589 ****
590 # Sender host name and address etc, all unset
591 exim -be
592 -oMa  sender_host_address = $sender_host_address
593       sender_host_port = $sender_host_port
594 -oMaa sender_host_authenticated = $sender_host_authenticated
595 -oMai authenticated_id = $authenticated_id
596 -oMas authenticated_sender = $authenticated_sender
597 -oMi  interface_address = $interface_address
598       interface_port = $interface_port
599 -oMr  received_protocol = $received_protocol
600 -oMs  sender_host_name = $sender_host_name
601 -oMt  sender_ident = $sender_ident
602 ****
603 # Sender host name and address etc, all set except host name.
604 exim -d-all+expand -be -oMa V4NET.0.0.1.1234 -oMaa AAA -oMai philip -oMas xx@yy.zz -oMi 1.1.1.1.99 -oMr special -oMt me
605 -oMa  sender_host_address = $sender_host_address
606       sender_host_port = $sender_host_port
607 -oMaa sender_host_authenticated = $sender_host_authenticated
608 -oMai authenticated_id = $authenticated_id
609 -oMas authenticated_sender = $authenticated_sender
610 -oMi  interface_address = $interface_address
611       interface_port = $interface_port
612 -oMr  received_protocol = $received_protocol
613 -oMt  sender_ident = $sender_ident
614 ****
615 # Sender host name explicitly set
616 exim -be -oMa V4NET.0.0.1.1234 -oMs my.host.name
617 -oMa  sender_host_address = $sender_host_address
618       sender_host_port = $sender_host_port
619 -oMs  sender_host_name = $sender_host_name
620 ****
621 # Sender host name lookup fails (V4NET.11.12.13 is not reverse registered)
622 exim -be -oMa V4NET.11.12.13
623 -oMs  sender_host_name = $sender_host_name
624       host_lookup_failed = $host_lookup_failed
625 ****
626 # Sender host name and protocol set by Sendmail-compatible option
627 exim -be -pspecial:host.name
628 -p  received_protocol = $received_protocol
629 -p  sender_host_name = $sender_host_name
630 ****
631 # Sender host name and address etc, all set except host name,
632 # which should therefore be looked up from the address, but not if
633 # we are skipping. The debug output for this test will show when
634 # the lookup occurs.
635 exim -d-all+host_lookup+expand -be -oMa V4NET.0.0.1.1234 -oMaa AAA -oMai philip -oMas xx@yy.zz -oMi 1.1.1.1.99 -oMr special -oMt me
636 -oMa  sender_host_address = $sender_host_address
637       sender_host_port = $sender_host_port
638 -oMaa sender_host_authenticated = $sender_host_authenticated
639 -oMai authenticated_id = $authenticated_id
640 -oMas authenticated_sender = $authenticated_sender
641 -oMi  interface_address = $interface_address
642       interface_port = $interface_port
643 -oMr  received_protocol = $received_protocol
644 ----> No lookup yet: ${if eq{black}{white}{$sender_host_name}{No}}
645 -oMs  sender_host_name = $sender_host_name
646 -oMt  sender_ident = $sender_ident
647 ****
648 # Test no auto host name lookup for query-style lookups
649 exim -d -bh V4NET.0.0.1
650 ****
651 exim -d -bh V4NET.0.0.2
652 ****
653 # Test $reply_address
654 exim -bh V4NET.0.0.0
655 mail from:<>
656 rcpt to:<some@body>
657 data
658 .
659 mail from:<>
660 rcpt to:<some@body>
661 data
662 From: a@b
663 .
664 mail from:<>
665 rcpt to:<some@body>
666 data
667 From: a@b
668 Reply-to: c@d
669 .
670 mail from:<>
671 rcpt to:<some@body>
672 data
673 Reply-to:
674 .
675 mail from:<>
676 rcpt to:<some@body>
677 data
678 Reply-to:
679 From: x@y
680 .
681 quit
682 ****
683 # Check RFC 2047 decoding with (default) length check
684 exim -bh V4NET.0.0.0
685 mail from:<>
686 rcpt to:<some@body>
687 data
688 Subject: =?iso-8859-8?Q?_here_we_go=3A_a_string_that_is_going_to_be_encoded=3A_it_will_go_over_the_75-char_limit_by_a_long_way=3B_in_fact_this_one_will_go_over_the_150_character_limit?=
689 .
690 quit
691 ****
692 # Check RFC 2047 decoding with length check disabled
693 exim -DLENCHECK=check_rfc2047_length=false -bh V4NET.0.0.0
694 mail from:<>
695 rcpt to:<some@body>
696 data
697 Subject: =?iso-8859-8?Q?_here_we_go=3A_a_string_that_is_going_to_be_encoded=3A_it_will_go_over_the_75-char_limit_by_a_long_way=3B_in_fact_this_one_will_go_over_the_150_character_limit?=
698 .
699 quit
700 ****
701 # Certain kind of error
702 exim -d -be
703 match_ip:        15 ${if match_ip{1.2.3.4}{1.2.3}}
704 match_ip:        16 ${if match_ip{1.2.3.4}{1.2.3.4/abc}}
705 ****