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}}
95 acl: ${acl {a_none}{person@dom.ain}}
97 acl: ${acl {a_deny}{person@dom.ain}}
98 acl: ${reduce {1:2:3:4} {} {$value ${acl {a_ret}{$item}}}}
100 addrss: ${address:local-part@dom.ain}
101 addrss: ${address:Exim Person <local-part@dom.ain> (that's me)}
102 domain: ${domain:local-part@dom.ain}
103 domain: ${domain:Exim Person <local-part@dom.ain> (that's me)}
105 addresses: ${addresses:>' 'abc@xyz, 'pqr@xyz}
106 addresses: ${addresses:Exim Person <local-part@dom.ain> (that's me)}
107 addresses: ${addresses:>+ Exim Person <local-part@dom.ain> (that's me),\
109 addresses: ${addresses:Exim Person <local-part@dom.ain> (that's me), \
110 xyz@abc, nullgroupname:;, group: p@q, r@s; }
111 addresses: ${addresses:local-part@dom.ain <local-part@dom.ain>}
113 escape: ${escape:B7·F2ò}
116 eval: ${eval:(1+2)*3}
122 eval: ${eval:-2 - -3}
123 eval: ${eval:-2 - (-3)}
124 eval: ${eval:-2 - (-3}
125 eval: ${eval:-2 - -3)}
128 eval: ${eval:-2 -+-3}
129 eval: ${eval:(2*(1+1))/2 + 40K}
132 eval10: ${eval10:077}
134 eval10: ${eval10:0x1234}
137 eval: ${eval:0xc & 5 }
141 eval: ${eval:0xc >> 2}
142 eval: ${eval:0xc >> 4 }
144 eval: ${eval:~255&0x1234}
145 eval: ${eval:~ 255&0x1234}
146 eval: ${eval: -(~255&0x1234)}
148 expand: \$primary_hostname ${expand:\$primary_hostname}
149 hash: ${hash_3:monty} ${hash_5:monty} ${hash_4_62:monty python}
150 hash: ${hash_3:abc}X ${hash_3:ab}X ${hash_3:a}X ${hash_3:}X
151 hex2b64:${hex2b64:12345678}
152 hex2b64:${hex2b64:abcdef}
153 hex2b64:${hex2b64:ABCDEF}
154 hex2b64:${hex2b64:1a2b3c4d5e6f}
155 hex2b64:${hex2b64:1a2b3c4d5e6}
156 hex2b64:${hex2b64:1a2b3c4d5e6g}
157 hex2b64:${hex2b64:${md5:the quick brown fox}}
158 hex2b64:${hex2b64:${sha1:the quick brown fox}}
160 The base62 operator is actually a base36 operator in the Darwin and Cygwin
161 environments. Write cunning tests that produce the same output in both cases,
162 while doing a reasonable check.
165 {eq {${base62:12345}}{0003D7}}\
166 {eq {${base62:12345}}{0009IX}}\
169 {eq {${base62d:0003D7}}{12345}}\
170 {eq {${base62d:0009IX}}{12345}}\
173 {eq {${base62d:3D7}}{12345}}\
174 {eq {${base62d:9IX}}{12345}}\
176 base62 error: ${base62:12345x}
177 base62d error:${base62d:0003D7.}
179 hmac: ${hmac{md5}{somesecret}{mail.example.com 2002-10-17 11:30:59}}
180 hmac: ${hmac{sha1}{somesecret}{mail.example.com 2002-10-17 11:30:59}}
181 md5: ${md5:the quick brown fox jumps over the lazy dog}
184 mask: ${mask:192.168.10.206/28}
185 mask: ${mask:192.168.10.206/32}
186 mask: ${mask:192.168.10.206/33}
187 mask: ${mask:192.168.10.206/0}
188 mask: ${mask:192.168.10.206}
189 mask: ${mask:a.b.c.d}
190 nhash: ${nhash_24:monty} ${nhash_8_63:monty python}
191 lc/uc: ${lc:The Quick} ${uc: Brown Fox}
192 length: ${length_10:The quick brown fox} ${l_10:abc}
193 lclpt: ${local_part:local-part@dom.ain}
194 lclpt: ${local_part:Exim Person <local-part@dom.ain> (that's me)}
195 quote: ${quote:aZ09_.-Q} ${quote:ab*cd} ${quote:ab\cd"ef}
196 quote: ${quote:nl(\n)}
197 quote: ${quote:cr(\r)}
198 quote: ${quote:tab(\t)}
199 quote: ${quote:xff(\xff)}
200 quote: Empty>${quote:}<
201 quote_local_part: ${quote_local_part:abcd}
202 quote_local_part: ${quote_local_part:O'Reilly}
203 quote_local_part: ${quote_local_part:a space}
204 quote_local_part: ${quote_local_part:.something}
205 quote_local_part: ${quote_local_part:something.}
206 quote_local_part: ${quote_local_part:joe.bloggs}
207 quote_local_part: ${quote_local_part:a!b}
208 quote_local_part: ${quote_local_part:x@y}
209 quote_local_part: ${quote_local_part:ab*cd}
210 quote_local_part: ${quote_local_part:x:y}
211 quote_local_part: ${quote_local_part:ab\cd"ef}
212 quote_local_part: ${quote_local_part:}
213 rxquote:${rxquote:aZ09_,-Q} ${rxquote:ab*cd} ${rxquote:ab\cd"ef}
214 substr: ${substr_3_2:rhubarb} ${s_-5_2:1234567} ${s_-5_2:12} ${s_-3_2:12}
215 substr: ${s_3:rhubarb} ${s_-2:rhubarb}
217 substr: ${substr_10:abc}
218 str2b64:${str2b64:abcd}
219 str2b64:${str2b64:The quick brown \n fox}
222 strlen: ${strlen:abcdefgh}
223 time_eval: ${time_eval:10s}
224 time_eval: ${time_eval:2h}
225 time_eval: ${time_eval:1d5m}
226 time_eval: ${time_eval:1w2d3h4m5s}
227 time_eval: ${time_eval:14}
228 time_eval: ${time_eval:rhubarb}
229 time_interval: ${time_interval:0}
230 time_interval: ${time_interval:44}
231 time_interval: ${time_interval:999999}
232 time_interval: ${time_interval:-1}
233 time_interval: ${time_interval:rhubarb}
235 # stat is a bit tricky, but some of the fields of the aux-var directory
236 # should be the same on all systems
238 stat: ${extract{mode}{${stat:DIR/aux-var}}}
239 stat: ${extract{smode}{${stat:DIR/aux-var}}}
240 stat: ${stat:/a/non/existent/file}
242 # "Operators" that have expanded arguments
244 hash: ${hash{3}{monty}} ${hash{5}{monty}} ${hash{4}{62}{monty python}}
245 hash: ${hash{3}{abc}}X ${hash{3}{ab}}X ${hash{3}{a}}X ${hash{3}{}}X
246 nhash: ${nhash{24}{monty}} ${nhash{8}{63}{monty python}}
247 length: ${length{10}{The quick brown fox}} ${length{10}{abc}}
248 substr: ${substr{3}{2}{rhubarb}} ${substr{-5}{2}{1234567}} ${substr{-5}{2}{12}} ${substr{-3}{2}{12}}
249 substr: ${substr{${if eq{1}{1}{-8}}}{${if eq{1}{0}{25}{1}}}{abcde}}
254 ${hash{nonnumber}{abcd}}
255 ${hash{3}{2}{4}{abcd}}
256 ${substr{-3}{-2}{abcd}}
260 addrss: ${if eq {1}{2}{${address:invalid}}{NO}}
261 domain: ${if eq {1}{2}{${domain:invalid}}{NO}}
262 escape: ${if eq {1}{2}{${escape:invalid}}{NO}}
263 expand: ${if eq {1}{2}{\$primary_hostname ${expand:\$invalid}}{NO}}
264 hash: ${if eq {1}{2}{${hash_3:invalid}}{NO}}
265 md5: ${if eq {1}{2}{${md5:invalid}}{NO}}
266 mask: ${if eq {1}{2}{${mask:invalid}}{NO}}
268 # Number suffixes in conditions
269 1k: ${if >{1}{1k}{n}{y}}
270 1K: ${if >{1}{1K}{n}{y}}
271 1M: ${if >{1}{1M}{n}{y}}
272 1G: ${if >{1}{1G}{n}{y}}
275 # >32b should work, >64b not
277 4096M ${if >{1}{4096M}{y}{n}}
278 4096000000 ${if >{1}{4096000000}{y}{n}}
279 4611686018427387904 ${if >{1}{4611686018427387904} {y}{n}}
280 46116860184273879040 ${if >{1}{46116860184273879040}{y}{n}}
284 2=2: ${if ={2}{2}{y}{n}}
285 2==2: ${if =={2}{2}{y}{n}}
286 3=2: ${if ={3}{2}{y}{n}}
287 2==3: ${if =={2}{3}{y}{n}}
288 !2=2: ${if !={2}{2}{y}{n}}
289 !2==2: ${if !=={2}{2}{y}{n}}
290 !3=2: ${if !={3}{2}{y}{n}}
291 !2==3: ${if !=={2}{3}{y}{n}}
292 2>3: ${if >{2}{3}{y}{n}}
293 3>3: ${if >{3}{3}{y}{n}}
294 4>3: ${if >{4}{3}{y}{n}}
295 1>-1: ${if >{1}{-1}{y}{n}}
296 2>=3: ${if >={2}{3}{y}{n}}
297 3>=3: ${if >={3}{3}{y}{n}}
298 4>=3: ${if >={4}{3}{y}{n}}
299 2<3: ${if <{2}{3}{y}{n}}
300 3<3: ${if <{3}{3}{y}{n}}
301 4<3: ${if <{4}{3}{y}{n}}
302 2<=3: ${if <={2}{3}{y}{n}}
303 3<=3: ${if <={3}{3}{y}{n}}
304 4<=3: ${if <={4}{3}{y}{n}}
305 5<=3: ${if <={ 5 } { 3 } {y}{n}}
306 -3<=1: ${if <={-3}{1}{y}{n}}
308 5>3k: ${if >{5 } {3k }{y}{n}}
309 5>3m: ${if >{5 } {3m }{y}{n}}
310 5>3z: ${if >{5 } {3z }{y}{n}}
311 5>a: ${if >{ 5 } {a}{y}{n}}
313 >0: ${if > {}{0}{y}{n}}
314 =: ${if = {}{}{y}{n}}
315 -2<: ${if < {-2}{}{y}{n}}
316 08>07: ${if > {08}{07}{y}{n}}
317 011=11: ${if = {011}{11}{y}{n}}
319 def:y ${if def:tod_log{y}{n}}
320 def:n ${if def:host{y}{n}}
321 def:f ${if def:post{y}{n}}
322 def:h_f ${if def:h_xxx {y}{n}}
323 def:h_f ${if def:h_xxx:{y}{n}}
324 def:d: ${if def:tod_log:{y}{n}}
326 exists: ${if exists{/etc/passwd}{y}{n}}
327 exists: ${if exists{/doesnt}{y}{n}}
329 eq: ${if eq{abc}{abc}{y}{n}}
330 eq: ${if eq{abc}{xyz}{y}{n}}
331 !eq: ${if !eq{abc}{abc}{y}{n}}
332 !eq: ${if !eq{abc}{xyz}{y}{n}}
334 eqi: ${if eqi{abc}{abc}{y}{n}}
335 eqi: ${if eqi{abc}{ABC}{y}{n}}
336 eqi: ${if eqi{abc}{xyz}{y}{n}}
337 !eqi: ${if !eqi{abc}{abc}{y}{n}}
338 !eqi: ${if !eqi{abc}{aBc}{y}{n}}
339 !eqi: ${if !eqi{abc}{xyz}{y}{n}}
341 lt: ${if lt{ABC}{abc}{y}{n}}
342 lti: ${if lti{ABC}{abc}{y}{n}}
343 le: ${if le{ABC}{abc}{y}{n}}
344 lei: ${if lei{ABC}{abc}{y}{n}}
345 gt: ${if gt{ABC}{abc}{y}{n}}
346 gti: ${if gti{ABC}{abc}{y}{n}}
347 ge: ${if ge{ABC}{abc}{y}{n}}
348 gei: ${if gei{ABC}{abc}{y}{n}}
350 isip: ${if isip {1.2.3.4}{y}{n}} 1.2.3.4
351 isip4: ${if isip4{1.2.3.4}{y}{n}} 1.2.3.4
352 isip6: ${if isip6{1.2.3.4}{y}{n}} 1.2.3.4
353 isip: ${if isip {1:2:3:4}{y}{n}} 1:2:3:4
354 isip4: ${if isip4{1:2:3:4}{y}{n}} 1:2:3:4
355 isip6: ${if isip6{1:2:3:4}{y}{n}} 1:2:3:4
356 isip: ${if isip {::1}{y}{n}} ::1
357 isip4: ${if isip4{::1}{y}{n}} ::1
358 isip6: ${if isip6{::1}{y}{n}} ::1
359 isip: ${if isip {fe80::a00:20ff:fe86:a061}{y}{n}} fe80::a00:20ff:fe86:a061
360 isip4: ${if isip4{fe80::a00:20ff:fe86:a061}{y}{n}} fe80::a00:20ff:fe86:a061
361 isip6: ${if isip6{fe80::a00:20ff:fe86:a061}{y}{n}} fe80::a00:20ff:fe86:a061
362 isip: ${if isip {rhubarb}{y}{n}} rhubarb
363 isip4: ${if isip4{rhubarb}{y}{n}} rhubarb
364 isip6: ${if isip6{rhubarb}{y}{n}} rhubarb
366 match: ${if match{abcd}{\N^([ab]+)(\w+)$\N}{$2$1}fail}
367 match: ${if match{abcd}{^\N([ab]+)(\w+)$\N}{$2$1}fail}
368 match: ${if match{abcd}{^([ab]+)(\\w+)\$}{$2$1}fail}
369 match: ${if match{wxyz}{^([ab]+)(\\w+)\$}{$2$1}fail}
370 match: ${if match{abcd}{^([ab]+)(\\w+)\$}{$2[${if match{xyz}{(.*)}{$1}fail}]$1}fail}
372 match_domain: ${if match_domain{a.b.c}{x.y.z:a.b.c:p.q.r}{yes}{no}}
373 match_domain: ${if match_domain{a.b.c}{x.y.z:p.q.r}{yes}{no}}
374 match_domain: ${if match_domain{5.aa.bb}{+dlist}{yes}{no}}
375 match_domain: ${if match_domain{xxxyz}{+dlist}{yes}{no}}
376 match_domain: ${if match_domain{xyz}{+dlist}{yes}{no}}
378 ${if match{x@zz.aa.bb}{^(.*)} \
381 ${if match_domain{${domain:$1}}{+dlist}{[$1]}} \
386 ${if match{x@xxxabc}{^(.*)} \
389 ${if match_domain{${domain:$1}}{^\Nxxx(.*)\N}{[$1]}} \
394 match_address: ${if match_address{x@y.z}{p@q:*@y.z}{yes}{no}}
395 match_address: ${if match_address{x@y.z}{p@q:x@*.z}{yes}{no}}
397 match_local_part:${if match_local_part{jo}{jack:jill:jo:john}{yes}{no}}
398 match_local_part:${if match_local_part{jo}{\N^\w\N}{yes}{no}}
400 match_ip: 01 ${if match_ip{1.2.3.4}{4.5.6.7:1.2.3.4}}
401 match_ip: 02 ${if match_ip{1.2.3.4}{4.5.6.7:1.2.3.6}}
402 match_ip: 03 ${if match_ip{1.2.3.4}{4.5.6.7:1.2.3.6/24}}
403 match_ip: 04 ${if match_ip{1.2.3.4}{4.5.6.7:1.2.3.6:*}}
404 match_ip: 05 ${if match_ip{1.2.3.4}{4.5.6.7:1.2.3.6:name}}
405 match_ip: 06 ${if match_ip{1.2.3.4}{:4.5.6.7}}
406 match_ip: 07 ${if match_ip{}{:4.5.6.7}}
407 match_ip: 08 ${if match_ip{V4NET.11.12.13}{+hlist}}
408 match_ip: 09 ${if match_ip{V4NET.11.12.14}{+hlist}}
409 match_ip: 10 ${if match_ip{192.168.3.4}{+hlist}}
410 match_ip: 11 ${if match_ip{somename}{+hlist}}
411 match_ip: 12 ${if match_ip{1.2.3.4}{lsearch;DIR/aux-fixed/0002.matchip}}
412 match_ip: 13 ${if match_ip{1.2.3.4}{net-lsearch;DIR/aux-fixed/0002.matchip}}
413 match_ip: 14 ${if match_ip{5.6.7.8}{net24-lsearch;DIR/aux-fixed/0002.matchip}}
414 match_ip: 15 ${if match_ip{abcd::dcba}{net-iplsearch;DIR/aux-fixed/0002.matchip}}
416 queue_running: ${if queue_running{y}{n}}
417 first_delivery: ${if first_delivery{y}{n}}
419 queue_running after or: ${if or{{eq {0}{0}}{queue_running}}{y}{n}}
420 first_delivery after or: ${if or{{eq {0}{0}}{first_delivery}}{y}{n}}
422 # Default values for both if strings
424 \${if eq{1}{1}} >${if eq{1}{1}}<
425 \${if eq{1}{2}} >${if eq{1}{2}}<
427 # Lookups: DIR is the testing directory. In this test we can only use the
428 # lookups that are required in all cases.
430 ${lookup{postmaster}lsearch{DIR/aux-fixed/0002.aliases}{$value}fail}
432 ${lookup{x@y}lsearch*@{DIR/aux-fixed/0002.starat}{$value}fail}
433 ${lookup{x@z}lsearch*{DIR/aux-fixed/0002.starat}{$value}fail}
434 ${lookup{x@z}lsearch*@{DIR/aux-fixed/0002.starat}{$value}fail}
435 ${lookup{x@w}lsearch*@{DIR/aux-fixed/0002.starat}{$value}fail}
437 ${lookup{a.b.c.d}partial-lsearch{DIR/aux-fixed/0002.domains}{$value}fail}
438 ${lookup{x.y.z}partial-lsearch{DIR/aux-fixed/0002.domains}{$value}{failed x.y.z}}
439 ${lookup{p.q}partial-lsearch{DIR/aux-fixed/0002.domains}{$value}fail}
440 ${lookup{o.p.q}partial-lsearch{DIR/aux-fixed/0002.domains}{$value}fail}
441 ${lookup{m.n.o.p.q}partial-lsearch{DIR/aux-fixed/0002.domains}{$value}fail}
442 ${lookup{x.y.z}partial1-lsearch{DIR/aux-fixed/0002.domains}{$value}fail}
443 ${lookup{x.y.z}partial0-lsearch{DIR/aux-fixed/0002.domains}{$value}fail}
445 q1: ${lookup{abc}lsearch{DIR/aux-fixed/0002.quoted}}
446 q2: ${lookup{xyz}lsearch{DIR/aux-fixed/0002.quoted}}
447 q3: ${lookup{pqr}lsearch{DIR/aux-fixed/0002.quoted}}
448 q4: ${lookup{a:b}lsearch{DIR/aux-fixed/0002.quoted}}
449 q5: ${lookup{"quoted"}lsearch{DIR/aux-fixed/0002.quoted}}
450 q6: ${lookup{white space}lsearch{DIR/aux-fixed/0002.quoted}}
451 q7: ${lookup{b\\s}lsearch{DIR/aux-fixed/0002.quoted}}
453 abc: ${lookup{abc}wildlsearch{DIR/aux-var/0002.wild}}
454 a.b.c: ${lookup{a.b.c}wildlsearch{DIR/aux-var/0002.wild}}
455 ab.c: ${lookup{ab.c}wildlsearch{DIR/aux-var/0002.wild}}
456 xyz: ${lookup{xyz}wildlsearch{DIR/aux-var/0002.wild}}
457 Xyz: ${lookup{Xyz}wildlsearch{DIR/aux-var/0002.wild}}
458 Zyz: ${lookup{Zyz}wildlsearch{DIR/aux-var/0002.wild}}
459 a b: ${lookup{a b}wildlsearch{DIR/aux-var/0002.wild}}
460 a b: ${lookup{a b}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 a9b: ${lookup{a9b}wildlsearch{DIR/aux-var/0002.wild}}
465 a99b: ${lookup{a99b}wildlsearch{DIR/aux-var/0002.wild}}
467 # Should give the same results as above because expansion does nothing
469 abc: ${lookup{abc}nwildlsearch{DIR/aux-var/0002.wild}}
470 a.b.c: ${lookup{a.b.c}nwildlsearch{DIR/aux-var/0002.wild}}
471 ab.c: ${lookup{ab.c}nwildlsearch{DIR/aux-var/0002.wild}}
472 xyz: ${lookup{xyz}nwildlsearch{DIR/aux-var/0002.wild}}
473 Xyz: ${lookup{Xyz}nwildlsearch{DIR/aux-var/0002.wild}}
474 Zyz: ${lookup{Zyz}nwildlsearch{DIR/aux-var/0002.wild}}
475 a b: ${lookup{a b}nwildlsearch{DIR/aux-var/0002.wild}}
476 a b: ${lookup{a b}nwildlsearch{DIR/aux-var/0002.wild}}
477 a:b: ${lookup{a:b}nwildlsearch{DIR/aux-var/0002.wild}}
479 # Should fail because of no expansion
481 a.b: ${lookup{a.b}nwildlsearch{DIR/aux-var/0002.wild}{$value}{NO}}
482 a..b: ${lookup{a..b}nwildlsearch{DIR/aux-var/0002.wild}{$value}{NO}}
483 a9b: ${lookup{a9b}nwildlsearch{DIR/aux-var/0002.wild}{$value}{NO}}
484 a99b: ${lookup{a99b}nwildlsearch{DIR/aux-var/0002.wild}{$value}{NO}}
486 # But these should succeed
488 a\\:b: ${lookup{a\\:b}nwildlsearch{DIR/aux-var/0002.wild}}
489 a\\:Xb: ${lookup{a\\:Xb}nwildlsearch{DIR/aux-var/0002.wild}}
491 # Some tests of case-(in)dependence
493 MiXeD-CD: ${lookup{MiXeD-CD}nwildlsearch{DIR/aux-var/0002.wild}{$value}{NOT FOUND}}
494 MixeD-CD: ${lookup{MixeD-CD}nwildlsearch{DIR/aux-var/0002.wild}{$value}{NOT FOUND}}
495 MiXeD-Ncd: ${lookup{MiXeD-Ncd}nwildlsearch{DIR/aux-var/0002.wild}{$value}{NOT FOUND}}
496 MixeD-Ncd: ${lookup{MixeD-Ncd}nwildlsearch{DIR/aux-var/0002.wild}{$value}{NOT FOUND}}
498 # IP address (CIDR) lookups
500 1.2.3.4: ${lookup{1.2.3.4}iplsearch{DIR/aux-fixed/0002.iplsearch}}
501 1.2.3.5: ${lookup{1.2.3.5}iplsearch{DIR/aux-fixed/0002.iplsearch}}
502 1.2.3.5: ${lookup{1.2.3.5}iplsearch*{DIR/aux-fixed/0002.iplsearch}}
503 abcd::cdab: ${lookup{abcd::cdab}iplsearch{DIR/aux-fixed/0002.iplsearch}}
504 192.168.1.2: ${lookup{192.168.1.2}iplsearch{DIR/aux-fixed/0002.iplsearch}}
505 192.168.5.6: ${lookup{192.168.5.6}iplsearch{DIR/aux-fixed/0002.iplsearch}}
506 abcd:abcd:: ${lookup{abcd:abcd::}iplsearch{DIR/aux-fixed/0002.iplsearch}}
507 abcd:abcd:1:: ${lookup{abcd:abcd:1::}iplsearch{DIR/aux-fixed/0002.iplsearch}}
508 abcd:abcd::3 ${lookup{abcd:abcd::3}iplsearch{DIR/aux-fixed/0002.iplsearch}}
509 rhubarb ${lookup{rhubarb}iplsearch{DIR/aux-fixed/0002.iplsearch}}
512 # Nested Lookups - style 1
514 ${lookup{${lookup{key1}lsearch{DIR/aux-fixed/0002.rec}{$value}{key1f}}}lsearch{DIR/aux-fixed/0002.rec}{$value}fail}
515 ${lookup{${lookup{key3}lsearch{DIR/aux-fixed/0002.rec}{$value}{key1f}}}lsearch{DIR/aux-fixed/0002.rec}{$value}fail}
517 # Nested Lookups - style 2
519 ${lookup{key1}lsearch{DIR/aux-fixed/0002.rec}{${lookup{$value}lsearch{DIR/aux-fixed/0002.rec}{$value}{failed for $value}}}{failed for key1}}
520 ${lookup{key3}lsearch{DIR/aux-fixed/0002.rec}{${lookup{$value}lsearch{DIR/aux-fixed/0002.rec}{$value}{failed for $value}}}{failed for key1}}
522 # Other nesting tests
524 ${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}}}
525 ${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}}}
526 ${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}}}
527 ${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}}}
529 # Lookup quotes for standardly expected lookups
531 lsearch ${quote_lsearch: !@#\$%^&*()_-+=|\\~`1234567890\{[\}]qwertyuiop:;"'asdfghjkl<,>.?/zxcvbnm}
532 xxx ${quote_xxx: !@#\$%^&*()_-+=|\\~`1234567890\{[\}]qwertyuiop:;"'asdfghjkl<,>.?/zxcvbnm}
536 ${extract{B}{A=1 B=2 C=3}}
537 ${extract{ B }{A=1 B=2 C=3}{$value}{NOT FOUND}}
538 ${extract{2}{:}{1:2:3}}
539 ${extract{ 2 }{:}{1:2:3}{$value}{NOT FOUND}}
540 Empty:<${extract{D}{A=1 B=2 C=3}}>
541 Empty:<${extract{4}{:}{1:2:3}}>
542 ${extract{C}{A=1 B=2 C=3}{<$value>}}
543 ${extract{3}{:}{1:2:3}{<$value>}}
544 Empty:<${extract{Z}{A=1 B=2 C=3}{<$value>}}>
545 Empty:<${extract{4}{:}{1:2:3}{<$value>}}>
546 ${extract{Z}{A=1 B=2 C=3}{<$value>}{no Z}}
547 ${extract{4}{:}{1:2:3}{<$value>}{no 4}}
548 ${extract{Z}{A=1 B=2 C=3}{<$value>}fail}
549 ${extract{4}{:}{1:2:3}{<$value>}fail}
550 ${extract{K4}{${sg{1=A 4=D 3=C}{(\\d+)=}{K\$1=}}}}
551 ${extract{0}{:}{a:b:c:d:e}{$value}{FAIL}}
552 ${extract{1}{:}{a:b:c:d:e}{$value}{FAIL}}
553 ${extract{-1}{:}{a:b:c:d:e}{$value}{FAIL}}
554 ${extract{-5}{:}{a:b:c:d:e}{$value}{FAIL}}
555 ${extract{-6}{:}{a:b:c:d:e}{$value}{FAIL}}
556 ${extract{-3}{:,}{a,,b::c}}
557 ${extract{2}{:,}{a,,b::c}}
558 ${extract{3}{:,}{a,,b::c}}
559 ${extract{a-b}{X = "one two" a-b "three four" 5=99}}
562 ${extract{ 2 }{ }{a b c}}
566 abcdea aaa xyz ${tr{abcdea}{aaa}{xyz}}
567 abcdea a z ${tr{abcdea}{a}{z}}
568 abcdea a ${tr{abcdea}{a}{}}
569 abcdea abc z ${tr{abcdea}{abc}{z}}
572 "TrUe" ${if bool{TrUe}{true}{false}} EXPECT: true
573 "FALSE" ${if bool{FALSE}{true}{false}} EXPECT: false
574 " yes" ${if bool{ yes}{true}{false}} EXPECT: true
575 " no" ${if bool{ no}{true}{false}} EXPECT: false
576 "yes " ${if bool{yes }{true}{false}} EXPECT: true
577 "-1" ${if bool{-1}{true}{false}} EXPECT: error
578 "0" ${if bool{0}{true}{false}} EXPECT: false
579 "1" ${if bool{1}{true}{false}} EXPECT: true
580 " 0 " ${if bool{ 0 }{true}{false}} EXPECT: false
581 " 1 " ${if bool{ 1 }{true}{false}} EXPECT: true
582 "1111111111111111111" ${if bool{1111111111111111111}{true}{false}} EXPECT: true
583 "9" ${if bool{9}{true}{false}} EXPECT: true
584 " " ${if bool{ }{true}{false}} EXPECT: false
585 "text" ${if bool{text}{true}{false}} EXPECT: error
586 " text" ${if bool{ text}{true}{false}} EXPECT: error
587 "text " ${if bool{text }{true}{false}} EXPECT: error
588 " text " ${if bool{ text }{true}{false}} EXPECT: error
589 "00" ${if bool{00}{true}{false}} EXPECT: false
590 "!true" ${if !bool{true}{true}{false}} EXPECT: false
591 "!false" ${if !bool{false}{true}{false}} EXPECT: true
593 "TrUe" ${if bool_lax{TrUe}{true}{false}} EXPECT: true
594 "FALSE" ${if bool_lax{FALSE}{true}{false}} EXPECT: false
595 " yes" ${if bool_lax{ yes}{true}{false}} EXPECT: true
596 " no" ${if bool_lax{ no}{true}{false}} EXPECT: false
597 "yes " ${if bool_lax{yes }{true}{false}} EXPECT: true
598 "-1" ${if bool_lax{-1}{true}{false}} EXPECT: true
599 "0" ${if bool_lax{0}{true}{false}} EXPECT: false
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 "1111111111111111111" ${if bool_lax{1111111111111111111}{true}{false}} EXPECT: true
604 "9" ${if bool_lax{9}{true}{false}} EXPECT: true
605 " " ${if bool_lax{ }{true}{false}} EXPECT: false
606 "text" ${if bool_lax{text}{true}{false}} EXPECT: true
607 " text" ${if bool_lax{ text}{true}{false}} EXPECT: true
608 "text " ${if bool_lax{text }{true}{false}} EXPECT: true
609 " text " ${if bool_lax{ text }{true}{false}} EXPECT: true
610 "00" ${if bool_lax{00}{true}{false}} EXPECT: true
611 "!true" ${if !bool_lax{true}{true}{false}} EXPECT: false
612 "!false" ${if !bool_lax{false}{true}{false}} EXPECT: true
617 <:abcd:> ${rfc2047:<:abcd:>}
618 <:ab cd:> ${rfc2047:<:ab cd:>}
619 Long: ${rfc2047: here we go: a string that is going to be encoded: it will go over the 75-char limit}
620 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}
624 ${rfc2047d:abcd abcd}
625 ${rfc2047d:<:abcd:> =?iso-8859-8?Q?=3C=3Aabcd=3A=3E?=}
626 ${rfc2047d:<:ab cd:> =?iso-8859-8?Q?=3C=3Aab_cd=3A=3E?=}
627 ${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?=}
628 ${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?=}
632 abcd ${from_utf8:abcd}
633 aÀÿd ${from_utf8:aÃ
\80ÿd}
634 toobig ${from_utf8:aĀd}
638 \${sg{abcdefabcdef}{abc}{xyz}} =${sg{abcdefabcdef}{abc}{xyz}}
639 \${sg{ab:xy::z}{:}{::}} =${sg{ab:xy::z}{:}{::}}
640 \${sg{abcdefabcdef}{(..)[^c]}{>\$1<}} =${sg{abcdefabcdef}{(..)[^c]}{>$1<}}
641 \${sg{abcdefabcdef}{(..)[^c]}{>\\\$1<}} =${sg{abcdefabcdef}{(..)[^c]}{>\$1<}}
642 \${sg{abcdefabcdef}{(..)[^c]}{>\\N\$1\\N<}}=${sg{abcdefabcdef}{(..)[^c]}{>\N$1\N<}}
643 \${sg{abbab}{a*}{+}} =${sg{abbab}{a*}{+}}
648 ${readfile{DIR/aux-fixed/0002.readfile}}
649 ${readfile{DIR/aux-fixed/0002.readfile}{}}
650 ${readfile{DIR/aux-fixed/0002.readfile}{:}}
651 ${readfile{DIR/aux-fixed/0002.readfile}{ - }}
652 ${readfile{/non/exist/file}}
653 ${if exists{/non/exist/file}{${readfile{/non/exist/file}}}{non-exist}}
654 >${readfile{DIR/aux-fixed/0002.readfile}{!}}\
659 ${run{DIR/aux-fixed/0002.runfile 0}}
661 ${run{DIR/aux-fixed/0002.runfile 0}{1}{2}}
663 ${run{DIR/aux-fixed/0002.runfile 0}{$value}{2}}
665 ${run{DIR/aux-fixed/0002.runfile 1}{$value}{2}}
667 ${run{DIR/aux-fixed/0002.runfile 1}{$value}{$value}}
669 ${run{DIR/test-nonexist}{Y}{N}}
671 >>${run{DIR/bin/iefbr14}}<<
673 ${if eq{1}{2}{${run{/non/exist}}}{1!=2}}
678 ${prvs{userx@test.ex}{secret}}
679 ${prvs{userx@test.ex}{secret}{1}}
680 ${prvs{userx@test.ex}{secret}{8}}
684 ${prvs{userx@test.ex}{secret}{12}}
685 ${prvs{userx@test.ex}{secret}{rhubarb}}
686 ${prvs{userx@test.ex}{secret}{}}
688 # Correct checks; can't put explicit addresses in the tests, because they
689 # will change over time.
691 ${prvscheck{${prvs{userx@test.ex}{secret}}}{secret}}
692 result=$prvscheck_result
694 ${prvscheck{${prvs{userx@test.ex}{secret}{1}}}{secret}\
695 {>$prvscheck_result< >$prvscheck_address< >$prvscheck_keynum<}}
696 result=$prvscheck_result
698 ${prvscheck{${prvs{userx@test.ex}{secret}{8}}}{secret}{}}
699 result=$prvscheck_result
703 ${prvscheck{${prvs{userx@test.ex}{secret}}}{socrot}}
704 result=$prvscheck_result
706 ${prvscheck{${prvs{userx@test.ex}{secret}}}{socrot}{$prvscheck_keynum}}
707 result=$prvscheck_result
711 >>${prvscheck{userx@test.ex}{secret}}<<
712 result=$prvscheck_result
719 ${expand:abcd${tod_log}
721 ${if and {xyz}{a}{b}}
722 ${if and {{xya}}{a}{b}}
723 ${if and {{${lookup{x}lsearch{/a/b}}}}{a}{b}}
724 ${if eq {$h_xyz}{1}{y}{n}}
725 ${if eq {$h_xyz:}{1}{y}{n}
726 ${if def:h_xyz}{y}{n}}
727 ${if or {eq {}{}{yes}{no}}
728 ${if or {{eq {}{}{yes}{no}}
729 ${if or {{eq {}{}}{yes}{no}}
733 # Iterations: forany and forall
735 ${if forany{a:b:c}{eq{$item}{a}}{yes}{no}}
736 ${if forany{a:b:c}{eq{$item}{b}}{yes}{no}}
737 ${if forany{a:b:c}{eq{$item}{c}}{yes}{no}}
738 ${if forany {a:b:c} {eq {$item} {z}} {yes} {no}}
739 ${if !forany{a:b:c}{eq{$item}{z}}{yes}{no}}
740 ${if !forany{a:b:c}{eq{$item}{a}}{yes}{no}}
741 ${if forany{}{eq{$item}{a}}{yes}{no}}
742 ${if !forany{}{eq{$item}{a}}{yes}{no}}
743 ${if forany{<, $primary_hostname,foo,bar}{eq{$item}{$primary_hostname}}{yes}{no}}
745 ${if forany{}{yes}{no}}
746 ${if forany{a:b:c}{gt{$item}{a}{yes}{no}}
748 ${if forall{a:b:c}{match{$item}{^[a-c]\$}}{yes}{no}}
749 ${if forall{q:b:c}{match{$item}{^[a-c]\$}}{yes}{no}}
750 ${if forall{a:b:z}{match{$item}{^[a-c]\$}}{yes}{no}}
751 ${if forall{}{match{$item}{^[a-c]\$}}{yes}{no}}
753 ${if !forall{a:b:c}{match{$item}{^[a-c]\$}}{yes}{no}}
754 ${if !forall{q:b:c}{match{$item}{^[a-c]\$}}{yes}{no}}
755 ${if !forall{a:b:z}{match{$item}{^[a-c]\$}}{yes}{no}}
756 ${if !forall{}{match{$item}{^[a-c]\$}}{yes}{no}}
762 {$item: ${if forall{x:y:z}{match{$item}{^[x-z]\$}}{true}{false}}}\
765 {outer=yes}{outer=no}} item='$item' (unset)
771 {$item: ${if !forall{x:y:z}{match{$item}{^[x-z]\$}}{true}{false}}}\
774 {outer=yes}{outer=no}}
776 # Error inside nest - check message is helpful
780 {$item: ${if forall{x:y:z}{match{$item}{^[x-z]\$}{true}{false}}}\
783 {outer=yes}{outer=no}}
786 # Miscellaneous (for bug fixes, etc)
788 ${if ={1}{1} {true}{${if ={1}{1} {true}{${if ={1}{1}{true}fail}}}}}
791 # Test "escape" with print_topbitchars
792 exim -be -DPTBC=print_topbitchars
793 escape: ${escape:B7·F2ò}
795 # Checkout expansion debugging
796 exim -d-all+expand -be
797 primary_hostname: $primary_hostname
798 match: ${if match{abcd}{\N^([ab]+)(\w+)$\N}{$2$1}fail}
799 match: ${if match{wxyz}{\N^([ab]+)(\w+)$\N}{$2$1}fail}
800 ${if eq {1}{1}{yes}{${lookup{xx}lsearch{/non/exist}}}}
801 match_address: ${if match_address{a.b.c}{a.b.c}{yes}{no}}
803 # Sender host name and address etc, all unset
805 -oMa sender_host_address = $sender_host_address
806 sender_host_port = $sender_host_port
807 -oMaa sender_host_authenticated = $sender_host_authenticated
808 -oMai authenticated_id = $authenticated_id
809 -oMas authenticated_sender = $authenticated_sender
810 -oMi interface_address = $interface_address
811 interface_port = $interface_port
812 -oMr received_protocol = $received_protocol
813 -oMs sender_host_name = $sender_host_name
814 -oMt sender_ident = $sender_ident
816 # Sender host name and address etc, all set except host name.
817 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
818 -oMa sender_host_address = $sender_host_address
819 sender_host_port = $sender_host_port
820 -oMaa sender_host_authenticated = $sender_host_authenticated
821 -oMai authenticated_id = $authenticated_id
822 -oMas authenticated_sender = $authenticated_sender
823 -oMi interface_address = $interface_address
824 interface_port = $interface_port
825 -oMr received_protocol = $received_protocol
826 -oMt sender_ident = $sender_ident
828 # Sender host name explicitly set
829 exim -be -oMa V4NET.0.0.1.1234 -oMs my.host.name
830 -oMa sender_host_address = $sender_host_address
831 sender_host_port = $sender_host_port
832 -oMs sender_host_name = $sender_host_name
834 # Sender host name lookup fails (V4NET.11.12.13 is not reverse registered)
835 exim -be -oMa V4NET.11.12.13
836 -oMs sender_host_name = $sender_host_name
837 host_lookup_failed = $host_lookup_failed
839 # Sender host name and protocol set by Sendmail-compatible option
840 exim -be -pspecial:host.name
841 -p received_protocol = $received_protocol
842 -p sender_host_name = $sender_host_name
844 # Sender host name and address etc, all set except host name,
845 # which should therefore be looked up from the address, but not if
846 # we are skipping. The debug output for this test will show when
848 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
849 -oMa sender_host_address = $sender_host_address
850 sender_host_port = $sender_host_port
851 -oMaa sender_host_authenticated = $sender_host_authenticated
852 -oMai authenticated_id = $authenticated_id
853 -oMas authenticated_sender = $authenticated_sender
854 -oMi interface_address = $interface_address
855 interface_port = $interface_port
856 -oMr received_protocol = $received_protocol
857 ----> No lookup yet: ${if eq{black}{white}{$sender_host_name}{No}}
858 -oMs sender_host_name = $sender_host_name
859 -oMt sender_ident = $sender_ident
861 # Test no auto host name lookup for query-style lookups
862 exim -d -bh V4NET.0.0.1
864 exim -d -bh V4NET.0.0.2
866 # Test $reply_address
896 # Check RFC 2047 decoding with (default) length check
901 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?=
905 # Check RFC 2047 decoding with length check disabled
906 exim -DLENCHECK=check_rfc2047_length=false -bh V4NET.0.0.0
910 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?=
914 # Certain kind of error
916 match_ip: 15 ${if match_ip{1.2.3.4}{1.2.3}}
917 match_ip: 16 ${if match_ip{1.2.3.4}{1.2.3.4/abc}}