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}}}
89 addrss: ${address:local-part@dom.ain}
90 addrss: ${address:Exim Person <local-part@dom.ain> (that's me)}
91 domain: ${domain:local-part@dom.ain}
92 domain: ${domain:Exim Person <local-part@dom.ain> (that's me)}
94 addresses: ${addresses:>' 'abc@xyz, 'pqr@xyz}
95 addresses: ${addresses:Exim Person <local-part@dom.ain> (that's me)}
96 addresses: ${addresses:>+ Exim Person <local-part@dom.ain> (that's me),\
98 addresses: ${addresses:Exim Person <local-part@dom.ain> (that's me), \
99 xyz@abc, nullgroupname:;, group: p@q, r@s; }
100 addresses: ${addresses:local-part@dom.ain <local-part@dom.ain>}
102 escape: ${escape:B7·F2ò}
105 eval: ${eval:(1+2)*3}
111 eval: ${eval:-2 - -3}
112 eval: ${eval:-2 - (-3)}
113 eval: ${eval:-2 - (-3}
114 eval: ${eval:-2 - -3)}
117 eval: ${eval:-2 -+-3}
118 eval: ${eval:(2*(1+1))/2 + 40K}
121 eval10: ${eval10:077}
123 eval10: ${eval10:0x1234}
126 eval: ${eval:0xc & 5 }
130 eval: ${eval:0xc >> 2}
131 eval: ${eval:0xc >> 4 }
133 eval: ${eval:~255&0x1234}
134 eval: ${eval:~ 255&0x1234}
135 eval: ${eval: -(~255&0x1234)}
137 expand: \$primary_hostname ${expand:\$primary_hostname}
138 hash: ${hash_3:monty} ${hash_5:monty} ${hash_4_62:monty python}
139 hash: ${hash_3:abc}X ${hash_3:ab}X ${hash_3:a}X ${hash_3:}X
140 hex2b64:${hex2b64:12345678}
141 hex2b64:${hex2b64:abcdef}
142 hex2b64:${hex2b64:ABCDEF}
143 hex2b64:${hex2b64:1a2b3c4d5e6f}
144 hex2b64:${hex2b64:1a2b3c4d5e6}
145 hex2b64:${hex2b64:1a2b3c4d5e6g}
146 hex2b64:${hex2b64:${md5:the quick brown fox}}
147 hex2b64:${hex2b64:${sha1:the quick brown fox}}
149 The base62 operator is actually a base36 operator in the Darwin and Cygwin
150 environments. Write cunning tests that produce the same output in both cases,
151 while doing a reasonable check.
154 {eq {${base62:12345}}{0003D7}}\
155 {eq {${base62:12345}}{0009IX}}\
158 {eq {${base62d:0003D7}}{12345}}\
159 {eq {${base62d:0009IX}}{12345}}\
162 {eq {${base62d:3D7}}{12345}}\
163 {eq {${base62d:9IX}}{12345}}\
165 base62 error: ${base62:12345x}
166 base62d error:${base62d:0003D7.}
168 hmac: ${hmac{md5}{somesecret}{mail.example.com 2002-10-17 11:30:59}}
169 hmac: ${hmac{sha1}{somesecret}{mail.example.com 2002-10-17 11:30:59}}
170 md5: ${md5:the quick brown fox jumps over the lazy dog}
173 mask: ${mask:192.168.10.206/28}
174 mask: ${mask:192.168.10.206/32}
175 mask: ${mask:192.168.10.206/33}
176 mask: ${mask:192.168.10.206/0}
177 mask: ${mask:192.168.10.206}
178 mask: ${mask:a.b.c.d}
179 nhash: ${nhash_24:monty} ${nhash_8_63:monty python}
180 lc/uc: ${lc:The Quick} ${uc: Brown Fox}
181 length: ${length_10:The quick brown fox} ${l_10:abc}
182 lclpt: ${local_part:local-part@dom.ain}
183 lclpt: ${local_part:Exim Person <local-part@dom.ain> (that's me)}
184 quote: ${quote:aZ09_.-Q} ${quote:ab*cd} ${quote:ab\cd"ef}
185 quote: ${quote:nl(\n)}
186 quote: ${quote:cr(\r)}
187 quote: ${quote:tab(\t)}
188 quote: ${quote:xff(\xff)}
189 quote: Empty>${quote:}<
190 quote_local_part: ${quote_local_part:abcd}
191 quote_local_part: ${quote_local_part:O'Reilly}
192 quote_local_part: ${quote_local_part:a space}
193 quote_local_part: ${quote_local_part:.something}
194 quote_local_part: ${quote_local_part:something.}
195 quote_local_part: ${quote_local_part:joe.bloggs}
196 quote_local_part: ${quote_local_part:a!b}
197 quote_local_part: ${quote_local_part:x@y}
198 quote_local_part: ${quote_local_part:ab*cd}
199 quote_local_part: ${quote_local_part:x:y}
200 quote_local_part: ${quote_local_part:ab\cd"ef}
201 quote_local_part: ${quote_local_part:}
202 rxquote:${rxquote:aZ09_,-Q} ${rxquote:ab*cd} ${rxquote:ab\cd"ef}
203 substr: ${substr_3_2:rhubarb} ${s_-5_2:1234567} ${s_-5_2:12} ${s_-3_2:12}
204 substr: ${s_3:rhubarb} ${s_-2:rhubarb}
206 substr: ${substr_10:abc}
207 str2b64:${str2b64:abcd}
208 str2b64:${str2b64:The quick brown \n fox}
211 strlen: ${strlen:abcdefgh}
212 time_eval: ${time_eval:10s}
213 time_eval: ${time_eval:2h}
214 time_eval: ${time_eval:1d5m}
215 time_eval: ${time_eval:1w2d3h4m5s}
216 time_eval: ${time_eval:14}
217 time_eval: ${time_eval:rhubarb}
218 time_interval: ${time_interval:0}
219 time_interval: ${time_interval:44}
220 time_interval: ${time_interval:999999}
221 time_interval: ${time_interval:-1}
222 time_interval: ${time_interval:rhubarb}
224 # stat is a bit tricky, but some of the fields of the aux-var directory
225 # should be the same on all systems
227 stat: ${extract{mode}{${stat:DIR/aux-var}}}
228 stat: ${extract{smode}{${stat:DIR/aux-var}}}
229 stat: ${stat:/a/non/existent/file}
231 # "Operators" that have expanded arguments
233 hash: ${hash{3}{monty}} ${hash{5}{monty}} ${hash{4}{62}{monty python}}
234 hash: ${hash{3}{abc}}X ${hash{3}{ab}}X ${hash{3}{a}}X ${hash{3}{}}X
235 nhash: ${nhash{24}{monty}} ${nhash{8}{63}{monty python}}
236 length: ${length{10}{The quick brown fox}} ${length{10}{abc}}
237 substr: ${substr{3}{2}{rhubarb}} ${substr{-5}{2}{1234567}} ${substr{-5}{2}{12}} ${substr{-3}{2}{12}}
238 substr: ${substr{${if eq{1}{1}{-8}}}{${if eq{1}{0}{25}{1}}}{abcde}}
243 ${hash{nonnumber}{abcd}}
244 ${hash{3}{2}{4}{abcd}}
245 ${substr{-3}{-2}{abcd}}
249 addrss: ${if eq {1}{2}{${address:invalid}}{NO}}
250 domain: ${if eq {1}{2}{${domain:invalid}}{NO}}
251 escape: ${if eq {1}{2}{${escape:invalid}}{NO}}
252 expand: ${if eq {1}{2}{\$primary_hostname ${expand:\$invalid}}{NO}}
253 hash: ${if eq {1}{2}{${hash_3:invalid}}{NO}}
254 md5: ${if eq {1}{2}{${md5:invalid}}{NO}}
255 mask: ${if eq {1}{2}{${mask:invalid}}{NO}}
257 # Number suffixes in conditions
258 1k: ${if >{1}{1k}{n}{y}}
259 1K: ${if >{1}{1K}{n}{y}}
260 1M: ${if >{1}{1M}{n}{y}}
261 1G: ${if >{1}{1G}{n}{y}}
264 # >32b should work, >64b not
266 4096M ${if >{1}{4096M}{y}{n}}
267 4096000000 ${if >{1}{4096000000}{y}{n}}
268 4611686018427387904 ${if >{1}{4611686018427387904} {y}{n}}
269 46116860184273879040 ${if >{1}{46116860184273879040}{y}{n}}
273 2=2: ${if ={2}{2}{y}{n}}
274 2==2: ${if =={2}{2}{y}{n}}
275 3=2: ${if ={3}{2}{y}{n}}
276 2==3: ${if =={2}{3}{y}{n}}
277 !2=2: ${if !={2}{2}{y}{n}}
278 !2==2: ${if !=={2}{2}{y}{n}}
279 !3=2: ${if !={3}{2}{y}{n}}
280 !2==3: ${if !=={2}{3}{y}{n}}
281 2>3: ${if >{2}{3}{y}{n}}
282 3>3: ${if >{3}{3}{y}{n}}
283 4>3: ${if >{4}{3}{y}{n}}
284 1>-1: ${if >{1}{-1}{y}{n}}
285 2>=3: ${if >={2}{3}{y}{n}}
286 3>=3: ${if >={3}{3}{y}{n}}
287 4>=3: ${if >={4}{3}{y}{n}}
288 2<3: ${if <{2}{3}{y}{n}}
289 3<3: ${if <{3}{3}{y}{n}}
290 4<3: ${if <{4}{3}{y}{n}}
291 2<=3: ${if <={2}{3}{y}{n}}
292 3<=3: ${if <={3}{3}{y}{n}}
293 4<=3: ${if <={4}{3}{y}{n}}
294 5<=3: ${if <={ 5 } { 3 } {y}{n}}
295 -3<=1: ${if <={-3}{1}{y}{n}}
297 5>3k: ${if >{5 } {3k }{y}{n}}
298 5>3m: ${if >{5 } {3m }{y}{n}}
299 5>3z: ${if >{5 } {3z }{y}{n}}
300 5>a: ${if >{ 5 } {a}{y}{n}}
302 >0: ${if > {}{0}{y}{n}}
303 =: ${if = {}{}{y}{n}}
304 -2<: ${if < {-2}{}{y}{n}}
305 08>07: ${if > {08}{07}{y}{n}}
306 011=11: ${if = {011}{11}{y}{n}}
308 def:y ${if def:tod_log{y}{n}}
309 def:n ${if def:host{y}{n}}
310 def:f ${if def:post{y}{n}}
311 def:h_f ${if def:h_xxx {y}{n}}
312 def:h_f ${if def:h_xxx:{y}{n}}
313 def:d: ${if def:tod_log:{y}{n}}
315 exists: ${if exists{/etc/passwd}{y}{n}}
316 exists: ${if exists{/doesnt}{y}{n}}
318 eq: ${if eq{abc}{abc}{y}{n}}
319 eq: ${if eq{abc}{xyz}{y}{n}}
320 !eq: ${if !eq{abc}{abc}{y}{n}}
321 !eq: ${if !eq{abc}{xyz}{y}{n}}
323 eqi: ${if eqi{abc}{abc}{y}{n}}
324 eqi: ${if eqi{abc}{ABC}{y}{n}}
325 eqi: ${if eqi{abc}{xyz}{y}{n}}
326 !eqi: ${if !eqi{abc}{abc}{y}{n}}
327 !eqi: ${if !eqi{abc}{aBc}{y}{n}}
328 !eqi: ${if !eqi{abc}{xyz}{y}{n}}
330 lt: ${if lt{ABC}{abc}{y}{n}}
331 lti: ${if lti{ABC}{abc}{y}{n}}
332 le: ${if le{ABC}{abc}{y}{n}}
333 lei: ${if lei{ABC}{abc}{y}{n}}
334 gt: ${if gt{ABC}{abc}{y}{n}}
335 gti: ${if gti{ABC}{abc}{y}{n}}
336 ge: ${if ge{ABC}{abc}{y}{n}}
337 gei: ${if gei{ABC}{abc}{y}{n}}
339 isip: ${if isip {1.2.3.4}{y}{n}} 1.2.3.4
340 isip4: ${if isip4{1.2.3.4}{y}{n}} 1.2.3.4
341 isip6: ${if isip6{1.2.3.4}{y}{n}} 1.2.3.4
342 isip: ${if isip {1:2:3:4}{y}{n}} 1:2:3:4
343 isip4: ${if isip4{1:2:3:4}{y}{n}} 1:2:3:4
344 isip6: ${if isip6{1:2:3:4}{y}{n}} 1:2:3:4
345 isip: ${if isip {::1}{y}{n}} ::1
346 isip4: ${if isip4{::1}{y}{n}} ::1
347 isip6: ${if isip6{::1}{y}{n}} ::1
348 isip: ${if isip {fe80::a00:20ff:fe86:a061}{y}{n}} fe80::a00:20ff:fe86:a061
349 isip4: ${if isip4{fe80::a00:20ff:fe86:a061}{y}{n}} fe80::a00:20ff:fe86:a061
350 isip6: ${if isip6{fe80::a00:20ff:fe86:a061}{y}{n}} fe80::a00:20ff:fe86:a061
351 isip: ${if isip {rhubarb}{y}{n}} rhubarb
352 isip4: ${if isip4{rhubarb}{y}{n}} rhubarb
353 isip6: ${if isip6{rhubarb}{y}{n}} rhubarb
355 match: ${if match{abcd}{\N^([ab]+)(\w+)$\N}{$2$1}fail}
356 match: ${if match{abcd}{^\N([ab]+)(\w+)$\N}{$2$1}fail}
357 match: ${if match{abcd}{^([ab]+)(\\w+)\$}{$2$1}fail}
358 match: ${if match{wxyz}{^([ab]+)(\\w+)\$}{$2$1}fail}
359 match: ${if match{abcd}{^([ab]+)(\\w+)\$}{$2[${if match{xyz}{(.*)}{$1}fail}]$1}fail}
361 match_domain: ${if match_domain{a.b.c}{x.y.z:a.b.c:p.q.r}{yes}{no}}
362 match_domain: ${if match_domain{a.b.c}{x.y.z:p.q.r}{yes}{no}}
363 match_domain: ${if match_domain{5.aa.bb}{+dlist}{yes}{no}}
364 match_domain: ${if match_domain{xxxyz}{+dlist}{yes}{no}}
365 match_domain: ${if match_domain{xyz}{+dlist}{yes}{no}}
367 ${if match{x@zz.aa.bb}{^(.*)} \
370 ${if match_domain{${domain:$1}}{+dlist}{[$1]}} \
375 ${if match{x@xxxabc}{^(.*)} \
378 ${if match_domain{${domain:$1}}{^\Nxxx(.*)\N}{[$1]}} \
383 match_address: ${if match_address{x@y.z}{p@q:*@y.z}{yes}{no}}
384 match_address: ${if match_address{x@y.z}{p@q:x@*.z}{yes}{no}}
386 match_local_part:${if match_local_part{jo}{jack:jill:jo:john}{yes}{no}}
387 match_local_part:${if match_local_part{jo}{\N^\w\N}{yes}{no}}
389 match_ip: 01 ${if match_ip{1.2.3.4}{4.5.6.7:1.2.3.4}}
390 match_ip: 02 ${if match_ip{1.2.3.4}{4.5.6.7:1.2.3.6}}
391 match_ip: 03 ${if match_ip{1.2.3.4}{4.5.6.7:1.2.3.6/24}}
392 match_ip: 04 ${if match_ip{1.2.3.4}{4.5.6.7:1.2.3.6:*}}
393 match_ip: 05 ${if match_ip{1.2.3.4}{4.5.6.7:1.2.3.6:name}}
394 match_ip: 06 ${if match_ip{1.2.3.4}{:4.5.6.7}}
395 match_ip: 07 ${if match_ip{}{:4.5.6.7}}
396 match_ip: 08 ${if match_ip{V4NET.11.12.13}{+hlist}}
397 match_ip: 09 ${if match_ip{V4NET.11.12.14}{+hlist}}
398 match_ip: 10 ${if match_ip{192.168.3.4}{+hlist}}
399 match_ip: 11 ${if match_ip{somename}{+hlist}}
400 match_ip: 12 ${if match_ip{1.2.3.4}{lsearch;DIR/aux-fixed/0002.matchip}}
401 match_ip: 13 ${if match_ip{1.2.3.4}{net-lsearch;DIR/aux-fixed/0002.matchip}}
402 match_ip: 14 ${if match_ip{5.6.7.8}{net24-lsearch;DIR/aux-fixed/0002.matchip}}
403 match_ip: 15 ${if match_ip{abcd::dcba}{net-iplsearch;DIR/aux-fixed/0002.matchip}}
405 queue_running: ${if queue_running{y}{n}}
406 first_delivery: ${if first_delivery{y}{n}}
408 queue_running after or: ${if or{{eq {0}{0}}{queue_running}}{y}{n}}
409 first_delivery after or: ${if or{{eq {0}{0}}{first_delivery}}{y}{n}}
411 # Default values for both if strings
413 \${if eq{1}{1}} >${if eq{1}{1}}<
414 \${if eq{1}{2}} >${if eq{1}{2}}<
416 # Lookups: DIR is the testing directory. In this test we can only use the
417 # lookups that are required in all cases.
419 ${lookup{postmaster}lsearch{DIR/aux-fixed/0002.aliases}{$value}fail}
421 ${lookup{x@y}lsearch*@{DIR/aux-fixed/0002.starat}{$value}fail}
422 ${lookup{x@z}lsearch*{DIR/aux-fixed/0002.starat}{$value}fail}
423 ${lookup{x@z}lsearch*@{DIR/aux-fixed/0002.starat}{$value}fail}
424 ${lookup{x@w}lsearch*@{DIR/aux-fixed/0002.starat}{$value}fail}
426 ${lookup{a.b.c.d}partial-lsearch{DIR/aux-fixed/0002.domains}{$value}fail}
427 ${lookup{x.y.z}partial-lsearch{DIR/aux-fixed/0002.domains}{$value}{failed x.y.z}}
428 ${lookup{p.q}partial-lsearch{DIR/aux-fixed/0002.domains}{$value}fail}
429 ${lookup{o.p.q}partial-lsearch{DIR/aux-fixed/0002.domains}{$value}fail}
430 ${lookup{m.n.o.p.q}partial-lsearch{DIR/aux-fixed/0002.domains}{$value}fail}
431 ${lookup{x.y.z}partial1-lsearch{DIR/aux-fixed/0002.domains}{$value}fail}
432 ${lookup{x.y.z}partial0-lsearch{DIR/aux-fixed/0002.domains}{$value}fail}
434 q1: ${lookup{abc}lsearch{DIR/aux-fixed/0002.quoted}}
435 q2: ${lookup{xyz}lsearch{DIR/aux-fixed/0002.quoted}}
436 q3: ${lookup{pqr}lsearch{DIR/aux-fixed/0002.quoted}}
437 q4: ${lookup{a:b}lsearch{DIR/aux-fixed/0002.quoted}}
438 q5: ${lookup{"quoted"}lsearch{DIR/aux-fixed/0002.quoted}}
439 q6: ${lookup{white space}lsearch{DIR/aux-fixed/0002.quoted}}
440 q7: ${lookup{b\\s}lsearch{DIR/aux-fixed/0002.quoted}}
442 abc: ${lookup{abc}wildlsearch{DIR/aux-var/0002.wild}}
443 a.b.c: ${lookup{a.b.c}wildlsearch{DIR/aux-var/0002.wild}}
444 ab.c: ${lookup{ab.c}wildlsearch{DIR/aux-var/0002.wild}}
445 xyz: ${lookup{xyz}wildlsearch{DIR/aux-var/0002.wild}}
446 Xyz: ${lookup{Xyz}wildlsearch{DIR/aux-var/0002.wild}}
447 Zyz: ${lookup{Zyz}wildlsearch{DIR/aux-var/0002.wild}}
448 a b: ${lookup{a b}wildlsearch{DIR/aux-var/0002.wild}}
449 a b: ${lookup{a b}wildlsearch{DIR/aux-var/0002.wild}}
450 a:b: ${lookup{a:b}wildlsearch{DIR/aux-var/0002.wild}}
451 a.b: ${lookup{a.b}wildlsearch{DIR/aux-var/0002.wild}}
452 a..b: ${lookup{a..b}wildlsearch{DIR/aux-var/0002.wild}}
453 a9b: ${lookup{a9b}wildlsearch{DIR/aux-var/0002.wild}}
454 a99b: ${lookup{a99b}wildlsearch{DIR/aux-var/0002.wild}}
456 # Should give the same results as above because expansion does nothing
458 abc: ${lookup{abc}nwildlsearch{DIR/aux-var/0002.wild}}
459 a.b.c: ${lookup{a.b.c}nwildlsearch{DIR/aux-var/0002.wild}}
460 ab.c: ${lookup{ab.c}nwildlsearch{DIR/aux-var/0002.wild}}
461 xyz: ${lookup{xyz}nwildlsearch{DIR/aux-var/0002.wild}}
462 Xyz: ${lookup{Xyz}nwildlsearch{DIR/aux-var/0002.wild}}
463 Zyz: ${lookup{Zyz}nwildlsearch{DIR/aux-var/0002.wild}}
464 a b: ${lookup{a b}nwildlsearch{DIR/aux-var/0002.wild}}
465 a b: ${lookup{a b}nwildlsearch{DIR/aux-var/0002.wild}}
466 a:b: ${lookup{a:b}nwildlsearch{DIR/aux-var/0002.wild}}
468 # Should fail because of no expansion
470 a.b: ${lookup{a.b}nwildlsearch{DIR/aux-var/0002.wild}{$value}{NO}}
471 a..b: ${lookup{a..b}nwildlsearch{DIR/aux-var/0002.wild}{$value}{NO}}
472 a9b: ${lookup{a9b}nwildlsearch{DIR/aux-var/0002.wild}{$value}{NO}}
473 a99b: ${lookup{a99b}nwildlsearch{DIR/aux-var/0002.wild}{$value}{NO}}
475 # But these should succeed
477 a\\:b: ${lookup{a\\:b}nwildlsearch{DIR/aux-var/0002.wild}}
478 a\\:Xb: ${lookup{a\\:Xb}nwildlsearch{DIR/aux-var/0002.wild}}
480 # Some tests of case-(in)dependence
482 MiXeD-CD: ${lookup{MiXeD-CD}nwildlsearch{DIR/aux-var/0002.wild}{$value}{NOT FOUND}}
483 MixeD-CD: ${lookup{MixeD-CD}nwildlsearch{DIR/aux-var/0002.wild}{$value}{NOT FOUND}}
484 MiXeD-Ncd: ${lookup{MiXeD-Ncd}nwildlsearch{DIR/aux-var/0002.wild}{$value}{NOT FOUND}}
485 MixeD-Ncd: ${lookup{MixeD-Ncd}nwildlsearch{DIR/aux-var/0002.wild}{$value}{NOT FOUND}}
487 # IP address (CIDR) lookups
489 1.2.3.4: ${lookup{1.2.3.4}iplsearch{DIR/aux-fixed/0002.iplsearch}}
490 1.2.3.5: ${lookup{1.2.3.5}iplsearch{DIR/aux-fixed/0002.iplsearch}}
491 1.2.3.5: ${lookup{1.2.3.5}iplsearch*{DIR/aux-fixed/0002.iplsearch}}
492 abcd::cdab: ${lookup{abcd::cdab}iplsearch{DIR/aux-fixed/0002.iplsearch}}
493 192.168.1.2: ${lookup{192.168.1.2}iplsearch{DIR/aux-fixed/0002.iplsearch}}
494 192.168.5.6: ${lookup{192.168.5.6}iplsearch{DIR/aux-fixed/0002.iplsearch}}
495 abcd:abcd:: ${lookup{abcd:abcd::}iplsearch{DIR/aux-fixed/0002.iplsearch}}
496 abcd:abcd:1:: ${lookup{abcd:abcd:1::}iplsearch{DIR/aux-fixed/0002.iplsearch}}
497 abcd:abcd::3 ${lookup{abcd:abcd::3}iplsearch{DIR/aux-fixed/0002.iplsearch}}
498 rhubarb ${lookup{rhubarb}iplsearch{DIR/aux-fixed/0002.iplsearch}}
501 # Nested Lookups - style 1
503 ${lookup{${lookup{key1}lsearch{DIR/aux-fixed/0002.rec}{$value}{key1f}}}lsearch{DIR/aux-fixed/0002.rec}{$value}fail}
504 ${lookup{${lookup{key3}lsearch{DIR/aux-fixed/0002.rec}{$value}{key1f}}}lsearch{DIR/aux-fixed/0002.rec}{$value}fail}
506 # Nested Lookups - style 2
508 ${lookup{key1}lsearch{DIR/aux-fixed/0002.rec}{${lookup{$value}lsearch{DIR/aux-fixed/0002.rec}{$value}{failed for $value}}}{failed for key1}}
509 ${lookup{key3}lsearch{DIR/aux-fixed/0002.rec}{${lookup{$value}lsearch{DIR/aux-fixed/0002.rec}{$value}{failed for $value}}}{failed for key1}}
511 # Other nesting tests
513 ${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}}}
514 ${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}}}
515 ${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}}}
516 ${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}}}
518 # Lookup quotes for standardly expected lookups
520 lsearch ${quote_lsearch: !@#\$%^&*()_-+=|\\~`1234567890\{[\}]qwertyuiop:;"'asdfghjkl<,>.?/zxcvbnm}
521 xxx ${quote_xxx: !@#\$%^&*()_-+=|\\~`1234567890\{[\}]qwertyuiop:;"'asdfghjkl<,>.?/zxcvbnm}
525 ${extract{B}{A=1 B=2 C=3}}
526 ${extract{ B }{A=1 B=2 C=3}{$value}{NOT FOUND}}
527 ${extract{2}{:}{1:2:3}}
528 ${extract{ 2 }{:}{1:2:3}{$value}{NOT FOUND}}
529 Empty:<${extract{D}{A=1 B=2 C=3}}>
530 Empty:<${extract{4}{:}{1:2:3}}>
531 ${extract{C}{A=1 B=2 C=3}{<$value>}}
532 ${extract{3}{:}{1:2:3}{<$value>}}
533 Empty:<${extract{Z}{A=1 B=2 C=3}{<$value>}}>
534 Empty:<${extract{4}{:}{1:2:3}{<$value>}}>
535 ${extract{Z}{A=1 B=2 C=3}{<$value>}{no Z}}
536 ${extract{4}{:}{1:2:3}{<$value>}{no 4}}
537 ${extract{Z}{A=1 B=2 C=3}{<$value>}fail}
538 ${extract{4}{:}{1:2:3}{<$value>}fail}
539 ${extract{K4}{${sg{1=A 4=D 3=C}{(\\d+)=}{K\$1=}}}}
540 ${extract{0}{:}{a:b:c:d:e}{$value}{FAIL}}
541 ${extract{1}{:}{a:b:c:d:e}{$value}{FAIL}}
542 ${extract{-1}{:}{a:b:c:d:e}{$value}{FAIL}}
543 ${extract{-5}{:}{a:b:c:d:e}{$value}{FAIL}}
544 ${extract{-6}{:}{a:b:c:d:e}{$value}{FAIL}}
545 ${extract{-3}{:,}{a,,b::c}}
546 ${extract{2}{:,}{a,,b::c}}
547 ${extract{3}{:,}{a,,b::c}}
548 ${extract{a-b}{X = "one two" a-b "three four" 5=99}}
551 ${extract{ 2 }{ }{a b c}}
555 abcdea aaa xyz ${tr{abcdea}{aaa}{xyz}}
556 abcdea a z ${tr{abcdea}{a}{z}}
557 abcdea a ${tr{abcdea}{a}{}}
558 abcdea abc z ${tr{abcdea}{abc}{z}}
561 "TrUe" ${if bool{TrUe}{true}{false}} EXPECT: true
562 "FALSE" ${if bool{FALSE}{true}{false}} EXPECT: false
563 " yes" ${if bool{ yes}{true}{false}} EXPECT: true
564 " no" ${if bool{ no}{true}{false}} EXPECT: false
565 "yes " ${if bool{yes }{true}{false}} EXPECT: true
566 "-1" ${if bool{-1}{true}{false}} EXPECT: error
567 "0" ${if bool{0}{true}{false}} EXPECT: false
568 "1" ${if bool{1}{true}{false}} EXPECT: true
569 " 0 " ${if bool{ 0 }{true}{false}} EXPECT: false
570 " 1 " ${if bool{ 1 }{true}{false}} EXPECT: true
571 "1111111111111111111" ${if bool{1111111111111111111}{true}{false}} EXPECT: true
572 "9" ${if bool{9}{true}{false}} EXPECT: true
573 " " ${if bool{ }{true}{false}} EXPECT: false
574 "text" ${if bool{text}{true}{false}} EXPECT: error
575 " text" ${if bool{ text}{true}{false}} EXPECT: error
576 "text " ${if bool{text }{true}{false}} EXPECT: error
577 " text " ${if bool{ text }{true}{false}} EXPECT: error
578 "00" ${if bool{00}{true}{false}} EXPECT: false
579 "!true" ${if !bool{true}{true}{false}} EXPECT: false
580 "!false" ${if !bool{false}{true}{false}} EXPECT: true
582 "TrUe" ${if bool_lax{TrUe}{true}{false}} EXPECT: true
583 "FALSE" ${if bool_lax{FALSE}{true}{false}} EXPECT: false
584 " yes" ${if bool_lax{ yes}{true}{false}} EXPECT: true
585 " no" ${if bool_lax{ no}{true}{false}} EXPECT: false
586 "yes " ${if bool_lax{yes }{true}{false}} EXPECT: true
587 "-1" ${if bool_lax{-1}{true}{false}} EXPECT: true
588 "0" ${if bool_lax{0}{true}{false}} EXPECT: false
589 "1" ${if bool_lax{1}{true}{false}} EXPECT: true
590 " 0 " ${if bool_lax{ 0 }{true}{false}} EXPECT: false
591 " 1 " ${if bool_lax{ 1 }{true}{false}} EXPECT: true
592 "1111111111111111111" ${if bool_lax{1111111111111111111}{true}{false}} EXPECT: true
593 "9" ${if bool_lax{9}{true}{false}} EXPECT: true
594 " " ${if bool_lax{ }{true}{false}} EXPECT: false
595 "text" ${if bool_lax{text}{true}{false}} EXPECT: true
596 " text" ${if bool_lax{ text}{true}{false}} EXPECT: true
597 "text " ${if bool_lax{text }{true}{false}} EXPECT: true
598 " text " ${if bool_lax{ text }{true}{false}} EXPECT: true
599 "00" ${if bool_lax{00}{true}{false}} EXPECT: true
600 "!true" ${if !bool_lax{true}{true}{false}} EXPECT: false
601 "!false" ${if !bool_lax{false}{true}{false}} EXPECT: true
606 <:abcd:> ${rfc2047:<:abcd:>}
607 <:ab cd:> ${rfc2047:<:ab cd:>}
608 Long: ${rfc2047: here we go: a string that is going to be encoded: it will go over the 75-char limit}
609 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}
613 ${rfc2047d:abcd abcd}
614 ${rfc2047d:<:abcd:> =?iso-8859-8?Q?=3C=3Aabcd=3A=3E?=}
615 ${rfc2047d:<:ab cd:> =?iso-8859-8?Q?=3C=3Aab_cd=3A=3E?=}
616 ${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?=}
617 ${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?=}
621 abcd ${from_utf8:abcd}
622 aÀÿd ${from_utf8:aÃ
\80ÿd}
623 toobig ${from_utf8:aĀd}
627 \${sg{abcdefabcdef}{abc}{xyz}} =${sg{abcdefabcdef}{abc}{xyz}}
628 \${sg{ab:xy::z}{:}{::}} =${sg{ab:xy::z}{:}{::}}
629 \${sg{abcdefabcdef}{(..)[^c]}{>\$1<}} =${sg{abcdefabcdef}{(..)[^c]}{>$1<}}
630 \${sg{abcdefabcdef}{(..)[^c]}{>\\\$1<}} =${sg{abcdefabcdef}{(..)[^c]}{>\$1<}}
631 \${sg{abcdefabcdef}{(..)[^c]}{>\\N\$1\\N<}}=${sg{abcdefabcdef}{(..)[^c]}{>\N$1\N<}}
632 \${sg{abbab}{a*}{+}} =${sg{abbab}{a*}{+}}
637 ${readfile{DIR/aux-fixed/0002.readfile}}
638 ${readfile{DIR/aux-fixed/0002.readfile}{}}
639 ${readfile{DIR/aux-fixed/0002.readfile}{:}}
640 ${readfile{DIR/aux-fixed/0002.readfile}{ - }}
641 ${readfile{/non/exist/file}}
642 ${if exists{/non/exist/file}{${readfile{/non/exist/file}}}{non-exist}}
643 >${readfile{DIR/aux-fixed/0002.readfile}{!}}\
648 ${run{DIR/aux-fixed/0002.runfile 0}}
650 ${run{DIR/aux-fixed/0002.runfile 0}{1}{2}}
652 ${run{DIR/aux-fixed/0002.runfile 0}{$value}{2}}
654 ${run{DIR/aux-fixed/0002.runfile 1}{$value}{2}}
656 ${run{DIR/aux-fixed/0002.runfile 1}{$value}{$value}}
658 ${run{DIR/test-nonexist}{Y}{N}}
660 >>${run{DIR/bin/iefbr14}}<<
662 ${if eq{1}{2}{${run{/non/exist}}}{1!=2}}
667 ${prvs{userx@test.ex}{secret}}
668 ${prvs{userx@test.ex}{secret}{1}}
669 ${prvs{userx@test.ex}{secret}{8}}
673 ${prvs{userx@test.ex}{secret}{12}}
674 ${prvs{userx@test.ex}{secret}{rhubarb}}
675 ${prvs{userx@test.ex}{secret}{}}
677 # Correct checks; can't put explicit addresses in the tests, because they
678 # will change over time.
680 ${prvscheck{${prvs{userx@test.ex}{secret}}}{secret}}
681 result=$prvscheck_result
683 ${prvscheck{${prvs{userx@test.ex}{secret}{1}}}{secret}\
684 {>$prvscheck_result< >$prvscheck_address< >$prvscheck_keynum<}}
685 result=$prvscheck_result
687 ${prvscheck{${prvs{userx@test.ex}{secret}{8}}}{secret}{}}
688 result=$prvscheck_result
692 ${prvscheck{${prvs{userx@test.ex}{secret}}}{socrot}}
693 result=$prvscheck_result
695 ${prvscheck{${prvs{userx@test.ex}{secret}}}{socrot}{$prvscheck_keynum}}
696 result=$prvscheck_result
700 >>${prvscheck{userx@test.ex}{secret}}<<
701 result=$prvscheck_result
708 ${expand:abcd${tod_log}
710 ${if and {xyz}{a}{b}}
711 ${if and {{xya}}{a}{b}}
712 ${if and {{${lookup{x}lsearch{/a/b}}}}{a}{b}}
713 ${if eq {$h_xyz}{1}{y}{n}}
714 ${if eq {$h_xyz:}{1}{y}{n}
715 ${if def:h_xyz}{y}{n}}
716 ${if or {eq {}{}{yes}{no}}
717 ${if or {{eq {}{}{yes}{no}}
718 ${if or {{eq {}{}}{yes}{no}}
722 # Iterations: forany and forall
724 ${if forany{a:b:c}{eq{$item}{a}}{yes}{no}}
725 ${if forany{a:b:c}{eq{$item}{b}}{yes}{no}}
726 ${if forany{a:b:c}{eq{$item}{c}}{yes}{no}}
727 ${if forany {a:b:c} {eq {$item} {z}} {yes} {no}}
728 ${if !forany{a:b:c}{eq{$item}{z}}{yes}{no}}
729 ${if !forany{a:b:c}{eq{$item}{a}}{yes}{no}}
730 ${if forany{}{eq{$item}{a}}{yes}{no}}
731 ${if !forany{}{eq{$item}{a}}{yes}{no}}
732 ${if forany{<, $primary_hostname,foo,bar}{eq{$item}{$primary_hostname}}{yes}{no}}
734 ${if forany{}{yes}{no}}
735 ${if forany{a:b:c}{gt{$item}{a}{yes}{no}}
737 ${if forall{a:b:c}{match{$item}{^[a-c]\$}}{yes}{no}}
738 ${if forall{q:b:c}{match{$item}{^[a-c]\$}}{yes}{no}}
739 ${if forall{a:b:z}{match{$item}{^[a-c]\$}}{yes}{no}}
740 ${if forall{}{match{$item}{^[a-c]\$}}{yes}{no}}
742 ${if !forall{a:b:c}{match{$item}{^[a-c]\$}}{yes}{no}}
743 ${if !forall{q:b:c}{match{$item}{^[a-c]\$}}{yes}{no}}
744 ${if !forall{a:b:z}{match{$item}{^[a-c]\$}}{yes}{no}}
745 ${if !forall{}{match{$item}{^[a-c]\$}}{yes}{no}}
751 {$item: ${if forall{x:y:z}{match{$item}{^[x-z]\$}}{true}{false}}}\
754 {outer=yes}{outer=no}} item='$item' (unset)
760 {$item: ${if !forall{x:y:z}{match{$item}{^[x-z]\$}}{true}{false}}}\
763 {outer=yes}{outer=no}}
765 # Error inside nest - check message is helpful
769 {$item: ${if forall{x:y:z}{match{$item}{^[x-z]\$}{true}{false}}}\
772 {outer=yes}{outer=no}}
775 # Miscellaneous (for bug fixes, etc)
777 ${if ={1}{1} {true}{${if ={1}{1} {true}{${if ={1}{1}{true}fail}}}}}
780 # Test "escape" with print_topbitchars
781 exim -be -DPTBC=print_topbitchars
782 escape: ${escape:B7·F2ò}
784 # Checkout expansion debugging
785 exim -d-all+expand -be
786 primary_hostname: $primary_hostname
787 match: ${if match{abcd}{\N^([ab]+)(\w+)$\N}{$2$1}fail}
788 match: ${if match{wxyz}{\N^([ab]+)(\w+)$\N}{$2$1}fail}
789 ${if eq {1}{1}{yes}{${lookup{xx}lsearch{/non/exist}}}}
790 match_address: ${if match_address{a.b.c}{a.b.c}{yes}{no}}
792 # Sender host name and address etc, all unset
794 -oMa sender_host_address = $sender_host_address
795 sender_host_port = $sender_host_port
796 -oMaa sender_host_authenticated = $sender_host_authenticated
797 -oMai authenticated_id = $authenticated_id
798 -oMas authenticated_sender = $authenticated_sender
799 -oMi interface_address = $interface_address
800 interface_port = $interface_port
801 -oMr received_protocol = $received_protocol
802 -oMs sender_host_name = $sender_host_name
803 -oMt sender_ident = $sender_ident
805 # Sender host name and address etc, all set except host name.
806 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
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 -oMt sender_ident = $sender_ident
817 # Sender host name explicitly set
818 exim -be -oMa V4NET.0.0.1.1234 -oMs my.host.name
819 -oMa sender_host_address = $sender_host_address
820 sender_host_port = $sender_host_port
821 -oMs sender_host_name = $sender_host_name
823 # Sender host name lookup fails (V4NET.11.12.13 is not reverse registered)
824 exim -be -oMa V4NET.11.12.13
825 -oMs sender_host_name = $sender_host_name
826 host_lookup_failed = $host_lookup_failed
828 # Sender host name and protocol set by Sendmail-compatible option
829 exim -be -pspecial:host.name
830 -p received_protocol = $received_protocol
831 -p sender_host_name = $sender_host_name
833 # Sender host name and address etc, all set except host name,
834 # which should therefore be looked up from the address, but not if
835 # we are skipping. The debug output for this test will show when
837 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
838 -oMa sender_host_address = $sender_host_address
839 sender_host_port = $sender_host_port
840 -oMaa sender_host_authenticated = $sender_host_authenticated
841 -oMai authenticated_id = $authenticated_id
842 -oMas authenticated_sender = $authenticated_sender
843 -oMi interface_address = $interface_address
844 interface_port = $interface_port
845 -oMr received_protocol = $received_protocol
846 ----> No lookup yet: ${if eq{black}{white}{$sender_host_name}{No}}
847 -oMs sender_host_name = $sender_host_name
848 -oMt sender_ident = $sender_ident
850 # Test no auto host name lookup for query-style lookups
851 exim -d -bh V4NET.0.0.1
853 exim -d -bh V4NET.0.0.2
855 # Test $reply_address
885 # Check RFC 2047 decoding with (default) length check
890 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?=
894 # Check RFC 2047 decoding with length check disabled
895 exim -DLENCHECK=check_rfc2047_length=false -bh V4NET.0.0.0
899 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?=
903 # Certain kind of error
905 match_ip: 15 ${if match_ip{1.2.3.4}{1.2.3}}
906 match_ip: 16 ${if match_ip{1.2.3.4}{1.2.3.4/abc}}