1 # Common string expansions
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.
11 # These expansions can test variables in the configuration, but as there
12 # is no message being processed, there is no message-related data. But
13 # that of course gets tested in plenty of other places.
15 # Some fixed variables
18 primary_hostname: $primary_hostname
19 primary_hostname: ${primary_hostname}
20 qualify_domain: $qualify_domain
21 bounce_return_size_limit: ${bounce_return_size_limit}
22 spool_directory: $spool_directory
24 h_subject: $h_subject:(should be empty)
25 h_subject:$h_subject (should be empty)
26 header in curlies: ${header_subject:} (should fail)
28 # \$message_headers should be empty
29 message_headers: >$message_headers<
37 # Overlong names and overbig numbers
39 +$aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
40 +${aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}
41 +$11111111111111111111111111111111111
42 +${11111111111111111111111111111111111}
46 filter: "${filter{a:b:c}{eq{1}{1}}}"
47 filter: ${filter{a:b:c}{!eq{$item}{b}}}
48 filter: ${filter{<' a'b'c}{!eq{$item}{b}}}
49 filter: ${filter{<' ''a'b' ''c}{!eq{$item}{b}}}
50 filter: "${filter{}{!eq{$item}{b}}}"
52 map: "${map{}{$item}}"
53 map: ${map{a:b:c}{$item}}
54 map: ${map{a:b:c}{:$item:}}
55 map: ${if eq{1}{0}{${map{a:b:c}{:$item:}}}{fail string}}
56 map: ${map{:b:c}{[$item]}}
58 reduce: "${reduce{}{+}{$value$item}}"
59 reduce: ${reduce{a:b:c}{+}{$value$item}}
60 reduce: ${reduce {<, 1,2,3}{0}{${eval:$value+$item}}}
61 reduce: ${reduce {3:0:9:4:6}{0}{${if >{$item}{$value}{$item}{$value}}}}
63 listnamed: ${listnamed:dlist}
64 listnamed: ${listnamed:+dlist}
65 listnamed: ${listnamed:hlist}
66 listnamed: ${listnamed:elist}
67 listnamed: ${listnamed:flist}
68 listnamed: ${listnamed:nolist}
69 listnamed: ${listnamed_d:dlist}
70 listnamed: ${listnamed_d:hlist}
71 listnamed: ${listnamed_z:dlist}
73 listcount: ${listcount:a:b:c}
74 listcount: ${listcount:}
75 listcount: ${listcount:<;a;b;c}
76 listcount: ${listcount:${listnamed:dlist}}
78 # Tests with iscntrl() and illegal separators
80 map: ${map{<\n a\n\nb\nc}{'$item'}}
82 reduce: ${reduce {<n 1\n2\n3}{0}{${eval:$value+$item}}}
83 reduce: ${reduce {<\n 1\n2\n3}{0}{${eval:$value+$item}}}
84 reduce: ${reduce { <\n 1\n 2 \n 3 }{0}{${eval:$value+$item}}}
85 reduce: ${reduce {<\x7f 1\x7f2\177 3}{0}{${eval:$value+$item}}}
93 acl: ${acl {a_ret}{person@dom.ain}}
94 acl: ${acl {a_ret}{firstarg}{secondarg}}
95 acl: ${acl {a_ret}{arg with spaces}}
97 acl: ${acl {a_none}{person@dom.ain}}
99 acl: ${acl {a_deny}{person@dom.ain}}
100 acl: ${reduce {1:2:3:4} {} {$value ${acl {a_ret}{$item}}}}
102 addrss: ${address:local-part@dom.ain}
103 addrss: ${address:Exim Person <local-part@dom.ain> (that's me)}
104 domain: ${domain:local-part@dom.ain}
105 domain: ${domain:Exim Person <local-part@dom.ain> (that's me)}
107 addresses: ${addresses:>' 'abc@xyz, 'pqr@xyz}
108 addresses: ${addresses:Exim Person <local-part@dom.ain> (that's me)}
109 addresses: ${addresses:>+ Exim Person <local-part@dom.ain> (that's me),\
111 addresses: ${addresses:Exim Person <local-part@dom.ain> (that's me), \
112 xyz@abc, nullgroupname:;, group: p@q, r@s; }
113 addresses: ${addresses:local-part@dom.ain <local-part@dom.ain>}
115 escape: ${escape:B7·F2ò}
118 eval: ${eval:(1+2)*3}
124 eval: ${eval:-2 - -3}
125 eval: ${eval:-2 - (-3)}
126 eval: ${eval:-2 - (-3}
127 eval: ${eval:-2 - -3)}
130 eval: ${eval:-2 -+-3}
131 eval: ${eval:(2*(1+1))/2 + 40K}
134 eval10: ${eval10:077}
136 eval10: ${eval10:0x1234}
139 eval: ${eval:0xc & 5 }
143 eval: ${eval:0xc >> 2}
144 eval: ${eval:0xc >> 4 }
146 eval: ${eval:~255&0x1234}
147 eval: ${eval:~ 255&0x1234}
148 eval: ${eval: -(~255&0x1234)}
150 expand: \$primary_hostname ${expand:\$primary_hostname}
151 hash: ${hash_3:monty} ${hash_5:monty} ${hash_4_62:monty python}
152 hash: ${hash_3:abc}X ${hash_3:ab}X ${hash_3:a}X ${hash_3:}X
153 hex2b64:${hex2b64:12345678}
154 hex2b64:${hex2b64:abcdef}
155 hex2b64:${hex2b64:ABCDEF}
156 hex2b64:${hex2b64:1a2b3c4d5e6f}
157 hex2b64:${hex2b64:1a2b3c4d5e6}
158 hex2b64:${hex2b64:1a2b3c4d5e6g}
159 hex2b64:${hex2b64:${md5:the quick brown fox}}
160 hex2b64:${hex2b64:${sha1:the quick brown fox}}
162 The base62 operator is actually a base36 operator in the Darwin and Cygwin
163 environments. Write cunning tests that produce the same output in both cases,
164 while doing a reasonable check.
167 {eq {${base62:12345}}{0003D7}}\
168 {eq {${base62:12345}}{0009IX}}\
171 {eq {${base62d:0003D7}}{12345}}\
172 {eq {${base62d:0009IX}}{12345}}\
175 {eq {${base62d:3D7}}{12345}}\
176 {eq {${base62d:9IX}}{12345}}\
178 base62 error: ${base62:12345x}
179 base62d error:${base62d:0003D7.}
181 hmac: ${hmac{md5}{somesecret}{mail.example.com 2002-10-17 11:30:59}}
182 hmac: ${hmac{sha1}{somesecret}{mail.example.com 2002-10-17 11:30:59}}
183 md5: ${md5:the quick brown fox jumps over the lazy dog}
186 mask: ${mask:192.168.10.206/28}
187 mask: ${mask:192.168.10.206/32}
188 mask: ${mask:192.168.10.206/33}
189 mask: ${mask:192.168.10.206/0}
190 mask: ${mask:192.168.10.206}
191 mask: ${mask:a.b.c.d}
192 nhash: ${nhash_24:monty} ${nhash_8_63:monty python}
193 lc/uc: ${lc:The Quick} ${uc: Brown Fox}
194 length: ${length_10:The quick brown fox} ${l_10:abc}
195 lclpt: ${local_part:local-part@dom.ain}
196 lclpt: ${local_part:Exim Person <local-part@dom.ain> (that's me)}
197 quote: ${quote:aZ09_.-Q} ${quote:ab*cd} ${quote:ab\cd"ef}
198 quote: ${quote:nl(\n)}
199 quote: ${quote:cr(\r)}
200 quote: ${quote:tab(\t)}
201 quote: ${quote:xff(\xff)}
202 quote: Empty>${quote:}<
203 quote_local_part: ${quote_local_part:abcd}
204 quote_local_part: ${quote_local_part:O'Reilly}
205 quote_local_part: ${quote_local_part:a space}
206 quote_local_part: ${quote_local_part:.something}
207 quote_local_part: ${quote_local_part:something.}
208 quote_local_part: ${quote_local_part:joe.bloggs}
209 quote_local_part: ${quote_local_part:a!b}
210 quote_local_part: ${quote_local_part:x@y}
211 quote_local_part: ${quote_local_part:ab*cd}
212 quote_local_part: ${quote_local_part:x:y}
213 quote_local_part: ${quote_local_part:ab\cd"ef}
214 quote_local_part: ${quote_local_part:}
215 rxquote:${rxquote:aZ09_,-Q} ${rxquote:ab*cd} ${rxquote:ab\cd"ef}
216 substr: ${substr_3_2:rhubarb} ${s_-5_2:1234567} ${s_-5_2:12} ${s_-3_2:12}
217 substr: ${s_3:rhubarb} ${s_-2:rhubarb}
219 substr: ${substr_10:abc}
220 str2b64:${str2b64:abcd}
221 str2b64:${str2b64:The quick brown \n fox}
224 strlen: ${strlen:abcdefgh}
225 time_eval: ${time_eval:10s}
226 time_eval: ${time_eval:2h}
227 time_eval: ${time_eval:1d5m}
228 time_eval: ${time_eval:1w2d3h4m5s}
229 time_eval: ${time_eval:14}
230 time_eval: ${time_eval:rhubarb}
231 time_interval: ${time_interval:0}
232 time_interval: ${time_interval:44}
233 time_interval: ${time_interval:999999}
234 time_interval: ${time_interval:-1}
235 time_interval: ${time_interval:rhubarb}
237 # stat is a bit tricky, but some of the fields of the aux-var directory
238 # should be the same on all systems
240 stat: ${extract{mode}{${stat:DIR/aux-var}}}
241 stat: ${extract{smode}{${stat:DIR/aux-var}}}
242 stat: ${stat:/a/non/existent/file}
244 # "Operators" that have expanded arguments
246 hash: ${hash{3}{monty}} ${hash{5}{monty}} ${hash{4}{62}{monty python}}
247 hash: ${hash{3}{abc}}X ${hash{3}{ab}}X ${hash{3}{a}}X ${hash{3}{}}X
248 nhash: ${nhash{24}{monty}} ${nhash{8}{63}{monty python}}
249 length: ${length{10}{The quick brown fox}} ${length{10}{abc}}
250 substr: ${substr{3}{2}{rhubarb}} ${substr{-5}{2}{1234567}} ${substr{-5}{2}{12}} ${substr{-3}{2}{12}}
251 substr: ${substr{${if eq{1}{1}{-8}}}{${if eq{1}{0}{25}{1}}}{abcde}}
256 ${hash{nonnumber}{abcd}}
257 ${hash{3}{2}{4}{abcd}}
258 ${substr{-3}{-2}{abcd}}
262 addrss: ${if eq {1}{2}{${address:invalid}}{NO}}
263 domain: ${if eq {1}{2}{${domain:invalid}}{NO}}
264 escape: ${if eq {1}{2}{${escape:invalid}}{NO}}
265 expand: ${if eq {1}{2}{\$primary_hostname ${expand:\$invalid}}{NO}}
266 hash: ${if eq {1}{2}{${hash_3:invalid}}{NO}}
267 md5: ${if eq {1}{2}{${md5:invalid}}{NO}}
268 mask: ${if eq {1}{2}{${mask:invalid}}{NO}}
270 # Number suffixes in conditions
271 1k: ${if >{1}{1k}{n}{y}}
272 1K: ${if >{1}{1K}{n}{y}}
273 1M: ${if >{1}{1M}{n}{y}}
274 1G: ${if >{1}{1G}{n}{y}}
277 # >32b should work, >64b not
279 4096M ${if >{1}{4096M}{y}{n}}
280 4096000000 ${if >{1}{4096000000}{y}{n}}
281 4611686018427387904 ${if >{1}{4611686018427387904} {y}{n}}
282 46116860184273879040 ${if >{1}{46116860184273879040}{y}{n}}
286 2=2: ${if ={2}{2}{y}{n}}
287 2==2: ${if =={2}{2}{y}{n}}
288 3=2: ${if ={3}{2}{y}{n}}
289 2==3: ${if =={2}{3}{y}{n}}
290 !2=2: ${if !={2}{2}{y}{n}}
291 !2==2: ${if !=={2}{2}{y}{n}}
292 !3=2: ${if !={3}{2}{y}{n}}
293 !2==3: ${if !=={2}{3}{y}{n}}
294 2>3: ${if >{2}{3}{y}{n}}
295 3>3: ${if >{3}{3}{y}{n}}
296 4>3: ${if >{4}{3}{y}{n}}
297 1>-1: ${if >{1}{-1}{y}{n}}
298 2>=3: ${if >={2}{3}{y}{n}}
299 3>=3: ${if >={3}{3}{y}{n}}
300 4>=3: ${if >={4}{3}{y}{n}}
301 2<3: ${if <{2}{3}{y}{n}}
302 3<3: ${if <{3}{3}{y}{n}}
303 4<3: ${if <{4}{3}{y}{n}}
304 2<=3: ${if <={2}{3}{y}{n}}
305 3<=3: ${if <={3}{3}{y}{n}}
306 4<=3: ${if <={4}{3}{y}{n}}
307 5<=3: ${if <={ 5 } { 3 } {y}{n}}
308 -3<=1: ${if <={-3}{1}{y}{n}}
310 5>3k: ${if >{5 } {3k }{y}{n}}
311 5>3m: ${if >{5 } {3m }{y}{n}}
312 5>3z: ${if >{5 } {3z }{y}{n}}
313 5>a: ${if >{ 5 } {a}{y}{n}}
315 >0: ${if > {}{0}{y}{n}}
316 =: ${if = {}{}{y}{n}}
317 -2<: ${if < {-2}{}{y}{n}}
318 08>07: ${if > {08}{07}{y}{n}}
319 011=11: ${if = {011}{11}{y}{n}}
321 def:y ${if def:tod_log{y}{n}}
322 def:n ${if def:host{y}{n}}
323 def:f ${if def:post{y}{n}}
324 def:h_f ${if def:h_xxx {y}{n}}
325 def:h_f ${if def:h_xxx:{y}{n}}
326 def:d: ${if def:tod_log:{y}{n}}
328 exists: ${if exists{/etc/passwd}{y}{n}}
329 exists: ${if exists{/doesnt}{y}{n}}
331 eq: ${if eq{abc}{abc}{y}{n}}
332 eq: ${if eq{abc}{xyz}{y}{n}}
333 !eq: ${if !eq{abc}{abc}{y}{n}}
334 !eq: ${if !eq{abc}{xyz}{y}{n}}
336 eqi: ${if eqi{abc}{abc}{y}{n}}
337 eqi: ${if eqi{abc}{ABC}{y}{n}}
338 eqi: ${if eqi{abc}{xyz}{y}{n}}
339 !eqi: ${if !eqi{abc}{abc}{y}{n}}
340 !eqi: ${if !eqi{abc}{aBc}{y}{n}}
341 !eqi: ${if !eqi{abc}{xyz}{y}{n}}
343 lt: ${if lt{ABC}{abc}{y}{n}}
344 lti: ${if lti{ABC}{abc}{y}{n}}
345 le: ${if le{ABC}{abc}{y}{n}}
346 lei: ${if lei{ABC}{abc}{y}{n}}
347 gt: ${if gt{ABC}{abc}{y}{n}}
348 gti: ${if gti{ABC}{abc}{y}{n}}
349 ge: ${if ge{ABC}{abc}{y}{n}}
350 gei: ${if gei{ABC}{abc}{y}{n}}
352 isip: ${if isip {1.2.3.4}{y}{n}} 1.2.3.4
353 isip4: ${if isip4{1.2.3.4}{y}{n}} 1.2.3.4
354 isip6: ${if isip6{1.2.3.4}{y}{n}} 1.2.3.4
355 isip: ${if isip {1:2:3:4}{y}{n}} 1:2:3:4
356 isip4: ${if isip4{1:2:3:4}{y}{n}} 1:2:3:4
357 isip6: ${if isip6{1:2:3:4}{y}{n}} 1:2:3:4
358 isip: ${if isip {::1}{y}{n}} ::1
359 isip4: ${if isip4{::1}{y}{n}} ::1
360 isip6: ${if isip6{::1}{y}{n}} ::1
361 isip: ${if isip {fe80::a00:20ff:fe86:a061}{y}{n}} fe80::a00:20ff:fe86:a061
362 isip4: ${if isip4{fe80::a00:20ff:fe86:a061}{y}{n}} fe80::a00:20ff:fe86:a061
363 isip6: ${if isip6{fe80::a00:20ff:fe86:a061}{y}{n}} fe80::a00:20ff:fe86:a061
364 isip: ${if isip {rhubarb}{y}{n}} rhubarb
365 isip4: ${if isip4{rhubarb}{y}{n}} rhubarb
366 isip6: ${if isip6{rhubarb}{y}{n}} rhubarb
368 match: ${if match{abcd}{\N^([ab]+)(\w+)$\N}{$2$1}fail}
369 match: ${if match{abcd}{^\N([ab]+)(\w+)$\N}{$2$1}fail}
370 match: ${if match{abcd}{^([ab]+)(\\w+)\$}{$2$1}fail}
371 match: ${if match{wxyz}{^([ab]+)(\\w+)\$}{$2$1}fail}
372 match: ${if match{abcd}{^([ab]+)(\\w+)\$}{$2[${if match{xyz}{(.*)}{$1}fail}]$1}fail}
374 match_domain: ${if match_domain{a.b.c}{x.y.z:a.b.c:p.q.r}{yes}{no}}
375 match_domain: ${if match_domain{a.b.c}{x.y.z:p.q.r}{yes}{no}}
376 match_domain: ${if match_domain{5.aa.bb}{+dlist}{yes}{no}}
377 match_domain: ${if match_domain{xxxyz}{+dlist}{yes}{no}}
378 match_domain: ${if match_domain{xyz}{+dlist}{yes}{no}}
380 ${if match{x@zz.aa.bb}{^(.*)} \
383 ${if match_domain{${domain:$1}}{+dlist}{[$1]}} \
388 ${if match{x@xxxabc}{^(.*)} \
391 ${if match_domain{${domain:$1}}{^\Nxxx(.*)\N}{[$1]}} \
396 match_address: ${if match_address{x@y.z}{p@q:*@y.z}{yes}{no}}
397 match_address: ${if match_address{x@y.z}{p@q:x@*.z}{yes}{no}}
399 match_local_part:${if match_local_part{jo}{jack:jill:jo:john}{yes}{no}}
400 match_local_part:${if match_local_part{jo}{\N^\w\N}{yes}{no}}
402 match_ip: 01 ${if match_ip{1.2.3.4}{4.5.6.7:1.2.3.4}}
403 match_ip: 02 ${if match_ip{1.2.3.4}{4.5.6.7:1.2.3.6}}
404 match_ip: 03 ${if match_ip{1.2.3.4}{4.5.6.7:1.2.3.6/24}}
405 match_ip: 04 ${if match_ip{1.2.3.4}{4.5.6.7:1.2.3.6:*}}
406 match_ip: 05 ${if match_ip{1.2.3.4}{4.5.6.7:1.2.3.6:name}}
407 match_ip: 06 ${if match_ip{1.2.3.4}{:4.5.6.7}}
408 match_ip: 07 ${if match_ip{}{:4.5.6.7}}
409 match_ip: 08 ${if match_ip{V4NET.11.12.13}{+hlist}}
410 match_ip: 09 ${if match_ip{V4NET.11.12.14}{+hlist}}
411 match_ip: 10 ${if match_ip{192.168.3.4}{+hlist}}
412 match_ip: 11 ${if match_ip{somename}{+hlist}}
413 match_ip: 12 ${if match_ip{1.2.3.4}{lsearch;DIR/aux-fixed/0002.matchip}}
414 match_ip: 13 ${if match_ip{1.2.3.4}{net-lsearch;DIR/aux-fixed/0002.matchip}}
415 match_ip: 14 ${if match_ip{5.6.7.8}{net24-lsearch;DIR/aux-fixed/0002.matchip}}
416 match_ip: 15 ${if match_ip{abcd::dcba}{net-iplsearch;DIR/aux-fixed/0002.matchip}}
418 queue_running: ${if queue_running{y}{n}}
419 first_delivery: ${if first_delivery{y}{n}}
421 queue_running after or: ${if or{{eq {0}{0}}{queue_running}}{y}{n}}
422 first_delivery after or: ${if or{{eq {0}{0}}{first_delivery}}{y}{n}}
424 # Default values for both if strings
426 \${if eq{1}{1}} >${if eq{1}{1}}<
427 \${if eq{1}{2}} >${if eq{1}{2}}<
429 # Lookups: DIR is the testing directory. In this test we can only use the
430 # lookups that are required in all cases.
432 ${lookup{postmaster}lsearch{DIR/aux-fixed/0002.aliases}{$value}fail}
434 ${lookup{x@y}lsearch*@{DIR/aux-fixed/0002.starat}{$value}fail}
435 ${lookup{x@z}lsearch*{DIR/aux-fixed/0002.starat}{$value}fail}
436 ${lookup{x@z}lsearch*@{DIR/aux-fixed/0002.starat}{$value}fail}
437 ${lookup{x@w}lsearch*@{DIR/aux-fixed/0002.starat}{$value}fail}
439 ${lookup{a.b.c.d}partial-lsearch{DIR/aux-fixed/0002.domains}{$value}fail}
440 ${lookup{x.y.z}partial-lsearch{DIR/aux-fixed/0002.domains}{$value}{failed x.y.z}}
441 ${lookup{p.q}partial-lsearch{DIR/aux-fixed/0002.domains}{$value}fail}
442 ${lookup{o.p.q}partial-lsearch{DIR/aux-fixed/0002.domains}{$value}fail}
443 ${lookup{m.n.o.p.q}partial-lsearch{DIR/aux-fixed/0002.domains}{$value}fail}
444 ${lookup{x.y.z}partial1-lsearch{DIR/aux-fixed/0002.domains}{$value}fail}
445 ${lookup{x.y.z}partial0-lsearch{DIR/aux-fixed/0002.domains}{$value}fail}
447 q1: ${lookup{abc}lsearch{DIR/aux-fixed/0002.quoted}}
448 q2: ${lookup{xyz}lsearch{DIR/aux-fixed/0002.quoted}}
449 q3: ${lookup{pqr}lsearch{DIR/aux-fixed/0002.quoted}}
450 q4: ${lookup{a:b}lsearch{DIR/aux-fixed/0002.quoted}}
451 q5: ${lookup{"quoted"}lsearch{DIR/aux-fixed/0002.quoted}}
452 q6: ${lookup{white space}lsearch{DIR/aux-fixed/0002.quoted}}
453 q7: ${lookup{b\\s}lsearch{DIR/aux-fixed/0002.quoted}}
455 abc: ${lookup{abc}wildlsearch{DIR/aux-var/0002.wild}}
456 a.b.c: ${lookup{a.b.c}wildlsearch{DIR/aux-var/0002.wild}}
457 ab.c: ${lookup{ab.c}wildlsearch{DIR/aux-var/0002.wild}}
458 xyz: ${lookup{xyz}wildlsearch{DIR/aux-var/0002.wild}}
459 Xyz: ${lookup{Xyz}wildlsearch{DIR/aux-var/0002.wild}}
460 Zyz: ${lookup{Zyz}wildlsearch{DIR/aux-var/0002.wild}}
461 a b: ${lookup{a b}wildlsearch{DIR/aux-var/0002.wild}}
462 a b: ${lookup{a b}wildlsearch{DIR/aux-var/0002.wild}}
463 a:b: ${lookup{a:b}wildlsearch{DIR/aux-var/0002.wild}}
464 a.b: ${lookup{a.b}wildlsearch{DIR/aux-var/0002.wild}}
465 a..b: ${lookup{a..b}wildlsearch{DIR/aux-var/0002.wild}}
466 a9b: ${lookup{a9b}wildlsearch{DIR/aux-var/0002.wild}}
467 a99b: ${lookup{a99b}wildlsearch{DIR/aux-var/0002.wild}}
469 # Should give the same results as above because expansion does nothing
471 abc: ${lookup{abc}nwildlsearch{DIR/aux-var/0002.wild}}
472 a.b.c: ${lookup{a.b.c}nwildlsearch{DIR/aux-var/0002.wild}}
473 ab.c: ${lookup{ab.c}nwildlsearch{DIR/aux-var/0002.wild}}
474 xyz: ${lookup{xyz}nwildlsearch{DIR/aux-var/0002.wild}}
475 Xyz: ${lookup{Xyz}nwildlsearch{DIR/aux-var/0002.wild}}
476 Zyz: ${lookup{Zyz}nwildlsearch{DIR/aux-var/0002.wild}}
477 a b: ${lookup{a b}nwildlsearch{DIR/aux-var/0002.wild}}
478 a b: ${lookup{a b}nwildlsearch{DIR/aux-var/0002.wild}}
479 a:b: ${lookup{a:b}nwildlsearch{DIR/aux-var/0002.wild}}
481 # Should fail because of no expansion
483 a.b: ${lookup{a.b}nwildlsearch{DIR/aux-var/0002.wild}{$value}{NO}}
484 a..b: ${lookup{a..b}nwildlsearch{DIR/aux-var/0002.wild}{$value}{NO}}
485 a9b: ${lookup{a9b}nwildlsearch{DIR/aux-var/0002.wild}{$value}{NO}}
486 a99b: ${lookup{a99b}nwildlsearch{DIR/aux-var/0002.wild}{$value}{NO}}
488 # But these should succeed
490 a\\:b: ${lookup{a\\:b}nwildlsearch{DIR/aux-var/0002.wild}}
491 a\\:Xb: ${lookup{a\\:Xb}nwildlsearch{DIR/aux-var/0002.wild}}
493 # Some tests of case-(in)dependence
495 MiXeD-CD: ${lookup{MiXeD-CD}nwildlsearch{DIR/aux-var/0002.wild}{$value}{NOT FOUND}}
496 MixeD-CD: ${lookup{MixeD-CD}nwildlsearch{DIR/aux-var/0002.wild}{$value}{NOT FOUND}}
497 MiXeD-Ncd: ${lookup{MiXeD-Ncd}nwildlsearch{DIR/aux-var/0002.wild}{$value}{NOT FOUND}}
498 MixeD-Ncd: ${lookup{MixeD-Ncd}nwildlsearch{DIR/aux-var/0002.wild}{$value}{NOT FOUND}}
500 # IP address (CIDR) lookups
502 1.2.3.4: ${lookup{1.2.3.4}iplsearch{DIR/aux-fixed/0002.iplsearch}}
503 1.2.3.5: ${lookup{1.2.3.5}iplsearch{DIR/aux-fixed/0002.iplsearch}}
504 1.2.3.5: ${lookup{1.2.3.5}iplsearch*{DIR/aux-fixed/0002.iplsearch}}
505 abcd::cdab: ${lookup{abcd::cdab}iplsearch{DIR/aux-fixed/0002.iplsearch}}
506 192.168.1.2: ${lookup{192.168.1.2}iplsearch{DIR/aux-fixed/0002.iplsearch}}
507 192.168.5.6: ${lookup{192.168.5.6}iplsearch{DIR/aux-fixed/0002.iplsearch}}
508 abcd:abcd:: ${lookup{abcd:abcd::}iplsearch{DIR/aux-fixed/0002.iplsearch}}
509 abcd:abcd:1:: ${lookup{abcd:abcd:1::}iplsearch{DIR/aux-fixed/0002.iplsearch}}
510 abcd:abcd::3 ${lookup{abcd:abcd::3}iplsearch{DIR/aux-fixed/0002.iplsearch}}
511 rhubarb ${lookup{rhubarb}iplsearch{DIR/aux-fixed/0002.iplsearch}}
514 # Nested Lookups - style 1
516 ${lookup{${lookup{key1}lsearch{DIR/aux-fixed/0002.rec}{$value}{key1f}}}lsearch{DIR/aux-fixed/0002.rec}{$value}fail}
517 ${lookup{${lookup{key3}lsearch{DIR/aux-fixed/0002.rec}{$value}{key1f}}}lsearch{DIR/aux-fixed/0002.rec}{$value}fail}
519 # Nested Lookups - style 2
521 ${lookup{key1}lsearch{DIR/aux-fixed/0002.rec}{${lookup{$value}lsearch{DIR/aux-fixed/0002.rec}{$value}{failed for $value}}}{failed for key1}}
522 ${lookup{key3}lsearch{DIR/aux-fixed/0002.rec}{${lookup{$value}lsearch{DIR/aux-fixed/0002.rec}{$value}{failed for $value}}}{failed for key1}}
524 # Other nesting tests
526 ${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}}}
527 ${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}}}
528 ${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}}}
529 ${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}}}
531 # Lookup quotes for standardly expected lookups
533 lsearch ${quote_lsearch: !@#\$%^&*()_-+=|\\~`1234567890\{[\}]qwertyuiop:;"'asdfghjkl<,>.?/zxcvbnm}
534 xxx ${quote_xxx: !@#\$%^&*()_-+=|\\~`1234567890\{[\}]qwertyuiop:;"'asdfghjkl<,>.?/zxcvbnm}
538 ${extract{B}{A=1 B=2 C=3}}
539 ${extract{ B }{A=1 B=2 C=3}{$value}{NOT FOUND}}
540 ${extract{2}{:}{1:2:3}}
541 ${extract{ 2 }{:}{1:2:3}{$value}{NOT FOUND}}
542 Empty:<${extract{D}{A=1 B=2 C=3}}>
543 Empty:<${extract{4}{:}{1:2:3}}>
544 ${extract{C}{A=1 B=2 C=3}{<$value>}}
545 ${extract{3}{:}{1:2:3}{<$value>}}
546 Empty:<${extract{Z}{A=1 B=2 C=3}{<$value>}}>
547 Empty:<${extract{4}{:}{1:2:3}{<$value>}}>
548 ${extract{Z}{A=1 B=2 C=3}{<$value>}{no Z}}
549 ${extract{4}{:}{1:2:3}{<$value>}{no 4}}
550 ${extract{Z}{A=1 B=2 C=3}{<$value>}fail}
551 ${extract{4}{:}{1:2:3}{<$value>}fail}
552 ${extract{K4}{${sg{1=A 4=D 3=C}{(\\d+)=}{K\$1=}}}}
553 ${extract{0}{:}{a:b:c:d:e}{$value}{FAIL}}
554 ${extract{1}{:}{a:b:c:d:e}{$value}{FAIL}}
555 ${extract{-1}{:}{a:b:c:d:e}{$value}{FAIL}}
556 ${extract{-5}{:}{a:b:c:d:e}{$value}{FAIL}}
557 ${extract{-6}{:}{a:b:c:d:e}{$value}{FAIL}}
558 ${extract{-3}{:,}{a,,b::c}}
559 ${extract{2}{:,}{a,,b::c}}
560 ${extract{3}{:,}{a,,b::c}}
561 ${extract{a-b}{X = "one two" a-b "three four" 5=99}}
564 ${extract{ 2 }{ }{a b c}}
568 abcdea aaa xyz ${tr{abcdea}{aaa}{xyz}}
569 abcdea a z ${tr{abcdea}{a}{z}}
570 abcdea a ${tr{abcdea}{a}{}}
571 abcdea abc z ${tr{abcdea}{abc}{z}}
574 "TrUe" ${if bool{TrUe}{true}{false}} EXPECT: true
575 "FALSE" ${if bool{FALSE}{true}{false}} EXPECT: false
576 " yes" ${if bool{ yes}{true}{false}} EXPECT: true
577 " no" ${if bool{ no}{true}{false}} EXPECT: false
578 "yes " ${if bool{yes }{true}{false}} EXPECT: true
579 "-1" ${if bool{-1}{true}{false}} EXPECT: error
580 "0" ${if bool{0}{true}{false}} EXPECT: false
581 "1" ${if bool{1}{true}{false}} EXPECT: true
582 " 0 " ${if bool{ 0 }{true}{false}} EXPECT: false
583 " 1 " ${if bool{ 1 }{true}{false}} EXPECT: true
584 "1111111111111111111" ${if bool{1111111111111111111}{true}{false}} EXPECT: true
585 "9" ${if bool{9}{true}{false}} EXPECT: true
586 " " ${if bool{ }{true}{false}} EXPECT: false
587 "text" ${if bool{text}{true}{false}} EXPECT: error
588 " text" ${if bool{ text}{true}{false}} EXPECT: error
589 "text " ${if bool{text }{true}{false}} EXPECT: error
590 " text " ${if bool{ text }{true}{false}} EXPECT: error
591 "00" ${if bool{00}{true}{false}} EXPECT: false
592 "!true" ${if !bool{true}{true}{false}} EXPECT: false
593 "!false" ${if !bool{false}{true}{false}} EXPECT: true
595 "TrUe" ${if bool_lax{TrUe}{true}{false}} EXPECT: true
596 "FALSE" ${if bool_lax{FALSE}{true}{false}} EXPECT: false
597 " yes" ${if bool_lax{ yes}{true}{false}} EXPECT: true
598 " no" ${if bool_lax{ no}{true}{false}} EXPECT: false
599 "yes " ${if bool_lax{yes }{true}{false}} EXPECT: true
600 "-1" ${if bool_lax{-1}{true}{false}} EXPECT: true
601 "0" ${if bool_lax{0}{true}{false}} EXPECT: false
602 "1" ${if bool_lax{1}{true}{false}} EXPECT: true
603 " 0 " ${if bool_lax{ 0 }{true}{false}} EXPECT: false
604 " 1 " ${if bool_lax{ 1 }{true}{false}} EXPECT: true
605 "1111111111111111111" ${if bool_lax{1111111111111111111}{true}{false}} EXPECT: true
606 "9" ${if bool_lax{9}{true}{false}} EXPECT: true
607 " " ${if bool_lax{ }{true}{false}} EXPECT: false
608 "text" ${if bool_lax{text}{true}{false}} EXPECT: true
609 " text" ${if bool_lax{ text}{true}{false}} EXPECT: true
610 "text " ${if bool_lax{text }{true}{false}} EXPECT: true
611 " text " ${if bool_lax{ text }{true}{false}} EXPECT: true
612 "00" ${if bool_lax{00}{true}{false}} EXPECT: true
613 "!true" ${if !bool_lax{true}{true}{false}} EXPECT: false
614 "!false" ${if !bool_lax{false}{true}{false}} EXPECT: true
619 <:abcd:> ${rfc2047:<:abcd:>}
620 <:ab cd:> ${rfc2047:<:ab cd:>}
621 Long: ${rfc2047: here we go: a string that is going to be encoded: it will go over the 75-char limit}
622 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}
626 ${rfc2047d:abcd abcd}
627 ${rfc2047d:<:abcd:> =?iso-8859-8?Q?=3C=3Aabcd=3A=3E?=}
628 ${rfc2047d:<:ab cd:> =?iso-8859-8?Q?=3C=3Aab_cd=3A=3E?=}
629 ${rfc2047d:Long: =?iso-8859-8?Q?_here_we_go=3A_a_string_that_is_going_to_be_encoded=3A_i?= =?iso-8859-8?Q?t_will_go_over_the_75-char_limit?=}
630 ${rfc2047d:Long: =?iso-8859-8?Q?_here_we_go=3A_a_string_that_is_going_to_be_encoded=3A_i?= =?iso-8859-8?Q?t_will_go_over_the_75-char_limit_by_a_long_way=3B_in_fac?= =?iso-8859-8?Q?t_this_one_will_go_over_the_150_character_limit?=}
634 abcd ${from_utf8:abcd}
635 aÀÿd ${from_utf8:aÃ
\80ÿd}
636 toobig ${from_utf8:aĀd}
640 \${sg{abcdefabcdef}{abc}{xyz}} =${sg{abcdefabcdef}{abc}{xyz}}
641 \${sg{ab:xy::z}{:}{::}} =${sg{ab:xy::z}{:}{::}}
642 \${sg{abcdefabcdef}{(..)[^c]}{>\$1<}} =${sg{abcdefabcdef}{(..)[^c]}{>$1<}}
643 \${sg{abcdefabcdef}{(..)[^c]}{>\\\$1<}} =${sg{abcdefabcdef}{(..)[^c]}{>\$1<}}
644 \${sg{abcdefabcdef}{(..)[^c]}{>\\N\$1\\N<}}=${sg{abcdefabcdef}{(..)[^c]}{>\N$1\N<}}
645 \${sg{abbab}{a*}{+}} =${sg{abbab}{a*}{+}}
650 ${readfile{DIR/aux-fixed/0002.readfile}}
651 ${readfile{DIR/aux-fixed/0002.readfile}{}}
652 ${readfile{DIR/aux-fixed/0002.readfile}{:}}
653 ${readfile{DIR/aux-fixed/0002.readfile}{ - }}
654 ${readfile{/non/exist/file}}
655 ${if exists{/non/exist/file}{${readfile{/non/exist/file}}}{non-exist}}
656 >${readfile{DIR/aux-fixed/0002.readfile}{!}}\
661 ${run{DIR/aux-fixed/0002.runfile 0}}
663 ${run{DIR/aux-fixed/0002.runfile 0}{1}{2}}
665 ${run{DIR/aux-fixed/0002.runfile 0}{$value}{2}}
667 ${run{DIR/aux-fixed/0002.runfile 1}{$value}{2}}
669 ${run{DIR/aux-fixed/0002.runfile 1}{$value}{$value}}
671 ${run{DIR/test-nonexist}{Y}{N}}
673 >>${run{DIR/bin/iefbr14}}<<
675 ${if eq{1}{2}{${run{/non/exist}}}{1!=2}}
680 ${prvs{userx@test.ex}{secret}}
681 ${prvs{userx@test.ex}{secret}{1}}
682 ${prvs{userx@test.ex}{secret}{8}}
686 ${prvs{userx@test.ex}{secret}{12}}
687 ${prvs{userx@test.ex}{secret}{rhubarb}}
688 ${prvs{userx@test.ex}{secret}{}}
690 # Correct checks; can't put explicit addresses in the tests, because they
691 # will change over time.
693 ${prvscheck{${prvs{userx@test.ex}{secret}}}{secret}}
694 result=$prvscheck_result
696 ${prvscheck{${prvs{userx@test.ex}{secret}{1}}}{secret}\
697 {>$prvscheck_result< >$prvscheck_address< >$prvscheck_keynum<}}
698 result=$prvscheck_result
700 ${prvscheck{${prvs{userx@test.ex}{secret}{8}}}{secret}{}}
701 result=$prvscheck_result
705 ${prvscheck{${prvs{userx@test.ex}{secret}}}{socrot}}
706 result=$prvscheck_result
708 ${prvscheck{${prvs{userx@test.ex}{secret}}}{socrot}{$prvscheck_keynum}}
709 result=$prvscheck_result
713 >>${prvscheck{userx@test.ex}{secret}}<<
714 result=$prvscheck_result
721 ${expand:abcd${tod_log}
723 ${if and {xyz}{a}{b}}
724 ${if and {{xya}}{a}{b}}
725 ${if and {{${lookup{x}lsearch{/a/b}}}}{a}{b}}
726 ${if eq {$h_xyz}{1}{y}{n}}
727 ${if eq {$h_xyz:}{1}{y}{n}
728 ${if def:h_xyz}{y}{n}}
729 ${if or {eq {}{}{yes}{no}}
730 ${if or {{eq {}{}{yes}{no}}
731 ${if or {{eq {}{}}{yes}{no}}
735 # Iterations: forany and forall
737 ${if forany{a:b:c}{eq{$item}{a}}{yes}{no}}
738 ${if forany{a:b:c}{eq{$item}{b}}{yes}{no}}
739 ${if forany{a:b:c}{eq{$item}{c}}{yes}{no}}
740 ${if forany {a:b:c} {eq {$item} {z}} {yes} {no}}
741 ${if !forany{a:b:c}{eq{$item}{z}}{yes}{no}}
742 ${if !forany{a:b:c}{eq{$item}{a}}{yes}{no}}
743 ${if forany{}{eq{$item}{a}}{yes}{no}}
744 ${if !forany{}{eq{$item}{a}}{yes}{no}}
745 ${if forany{<, $primary_hostname,foo,bar}{eq{$item}{$primary_hostname}}{yes}{no}}
747 ${if forany{}{yes}{no}}
748 ${if forany{a:b:c}{gt{$item}{a}{yes}{no}}
750 ${if forall{a:b:c}{match{$item}{^[a-c]\$}}{yes}{no}}
751 ${if forall{q:b:c}{match{$item}{^[a-c]\$}}{yes}{no}}
752 ${if forall{a:b:z}{match{$item}{^[a-c]\$}}{yes}{no}}
753 ${if forall{}{match{$item}{^[a-c]\$}}{yes}{no}}
755 ${if !forall{a:b:c}{match{$item}{^[a-c]\$}}{yes}{no}}
756 ${if !forall{q:b:c}{match{$item}{^[a-c]\$}}{yes}{no}}
757 ${if !forall{a:b:z}{match{$item}{^[a-c]\$}}{yes}{no}}
758 ${if !forall{}{match{$item}{^[a-c]\$}}{yes}{no}}
764 {$item: ${if forall{x:y:z}{match{$item}{^[x-z]\$}}{true}{false}}}\
767 {outer=yes}{outer=no}} item='$item' (unset)
773 {$item: ${if !forall{x:y:z}{match{$item}{^[x-z]\$}}{true}{false}}}\
776 {outer=yes}{outer=no}}
778 # Error inside nest - check message is helpful
782 {$item: ${if forall{x:y:z}{match{$item}{^[x-z]\$}{true}{false}}}\
785 {outer=yes}{outer=no}}
788 # Miscellaneous (for bug fixes, etc)
790 ${if ={1}{1} {true}{${if ={1}{1} {true}{${if ={1}{1}{true}fail}}}}}
793 # Test "escape" with print_topbitchars
794 exim -be -DPTBC=print_topbitchars
795 escape: ${escape:B7·F2ò}
797 # Checkout expansion debugging
798 exim -d-all+expand -be
799 primary_hostname: $primary_hostname
800 match: ${if match{abcd}{\N^([ab]+)(\w+)$\N}{$2$1}fail}
801 match: ${if match{wxyz}{\N^([ab]+)(\w+)$\N}{$2$1}fail}
802 ${if eq {1}{1}{yes}{${lookup{xx}lsearch{/non/exist}}}}
803 match_address: ${if match_address{a.b.c}{a.b.c}{yes}{no}}
805 # Sender host name and address etc, all unset
807 -oMa sender_host_address = $sender_host_address
808 sender_host_port = $sender_host_port
809 -oMaa sender_host_authenticated = $sender_host_authenticated
810 -oMai authenticated_id = $authenticated_id
811 -oMas authenticated_sender = $authenticated_sender
812 -oMi interface_address = $interface_address
813 interface_port = $interface_port
814 -oMr received_protocol = $received_protocol
815 -oMs sender_host_name = $sender_host_name
816 -oMt sender_ident = $sender_ident
818 # Sender host name and address etc, all set except host name.
819 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
820 -oMa sender_host_address = $sender_host_address
821 sender_host_port = $sender_host_port
822 -oMaa sender_host_authenticated = $sender_host_authenticated
823 -oMai authenticated_id = $authenticated_id
824 -oMas authenticated_sender = $authenticated_sender
825 -oMi interface_address = $interface_address
826 interface_port = $interface_port
827 -oMr received_protocol = $received_protocol
828 -oMt sender_ident = $sender_ident
830 # Sender host name explicitly set
831 exim -be -oMa V4NET.0.0.1.1234 -oMs my.host.name
832 -oMa sender_host_address = $sender_host_address
833 sender_host_port = $sender_host_port
834 -oMs sender_host_name = $sender_host_name
836 # Sender host name lookup fails (V4NET.11.12.13 is not reverse registered)
837 exim -be -oMa V4NET.11.12.13
838 -oMs sender_host_name = $sender_host_name
839 host_lookup_failed = $host_lookup_failed
841 # Sender host name and protocol set by Sendmail-compatible option
842 exim -be -pspecial:host.name
843 -p received_protocol = $received_protocol
844 -p sender_host_name = $sender_host_name
846 # Sender host name and address etc, all set except host name,
847 # which should therefore be looked up from the address, but not if
848 # we are skipping. The debug output for this test will show when
850 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
851 -oMa sender_host_address = $sender_host_address
852 sender_host_port = $sender_host_port
853 -oMaa sender_host_authenticated = $sender_host_authenticated
854 -oMai authenticated_id = $authenticated_id
855 -oMas authenticated_sender = $authenticated_sender
856 -oMi interface_address = $interface_address
857 interface_port = $interface_port
858 -oMr received_protocol = $received_protocol
859 ----> No lookup yet: ${if eq{black}{white}{$sender_host_name}{No}}
860 -oMs sender_host_name = $sender_host_name
861 -oMt sender_ident = $sender_ident
863 # Test no auto host name lookup for query-style lookups
864 exim -d -bh V4NET.0.0.1
866 exim -d -bh V4NET.0.0.2
868 # Test $reply_address
898 # Check RFC 2047 decoding with (default) length check
903 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?=
907 # Check RFC 2047 decoding with length check disabled
908 exim -DLENCHECK=check_rfc2047_length=false -bh V4NET.0.0.0
912 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?=
916 # Certain kind of error
918 match_ip: 15 ${if match_ip{1.2.3.4}{1.2.3}}
919 match_ip: 16 ${if match_ip{1.2.3.4}{1.2.3.4/abc}}