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 # Tests with iscntrl() and illegal separators
65 map: ${map{<\n a\n\nb\nc}{'$item'}}
67 reduce: ${reduce {<n 1\n2\n3}{0}{${eval:$value+$item}}}
68 reduce: ${reduce {<\n 1\n2\n3}{0}{${eval:$value+$item}}}
69 reduce: ${reduce { <\n 1\n 2 \n 3 }{0}{${eval:$value+$item}}}
70 reduce: ${reduce {<\x7f 1\x7f2\177 3}{0}{${eval:$value+$item}}}
74 addrss: ${address:local-part@dom.ain}
75 addrss: ${address:Exim Person <local-part@dom.ain> (that's me)}
76 domain: ${domain:local-part@dom.ain}
77 domain: ${domain:Exim Person <local-part@dom.ain> (that's me)}
79 addresses: ${addresses:>' 'abc@xyz, 'pqr@xyz}
80 addresses: ${addresses:Exim Person <local-part@dom.ain> (that's me)}
81 addresses: ${addresses:>+ Exim Person <local-part@dom.ain> (that's me),\
83 addresses: ${addresses:Exim Person <local-part@dom.ain> (that's me), \
84 xyz@abc, nullgroupname:;, group: p@q, r@s; }
85 addresses: ${addresses:local-part@dom.ain <local-part@dom.ain>}
87 escape: ${escape:B7·F2ò}
97 eval: ${eval:-2 - (-3)}
98 eval: ${eval:-2 - (-3}
99 eval: ${eval:-2 - -3)}
102 eval: ${eval:-2 -+-3}
103 eval: ${eval:(2*(1+1))/2 + 40K}
106 eval10: ${eval10:077}
108 eval10: ${eval10:0x1234}
111 eval: ${eval:0xc & 5 }
115 eval: ${eval:0xc >> 2}
116 eval: ${eval:0xc >> 4 }
118 eval: ${eval:~255&0x1234}
119 eval: ${eval:~ 255&0x1234}
120 eval: ${eval: -(~255&0x1234)}
122 expand: \$primary_hostname ${expand:\$primary_hostname}
123 hash: ${hash_3:monty} ${hash_5:monty} ${hash_4_62:monty python}
124 hash: ${hash_3:abc}X ${hash_3:ab}X ${hash_3:a}X ${hash_3:}X
125 hex2b64:${hex2b64:12345678}
126 hex2b64:${hex2b64:abcdef}
127 hex2b64:${hex2b64:ABCDEF}
128 hex2b64:${hex2b64:1a2b3c4d5e6f}
129 hex2b64:${hex2b64:1a2b3c4d5e6}
130 hex2b64:${hex2b64:1a2b3c4d5e6g}
131 hex2b64:${hex2b64:${md5:the quick brown fox}}
132 hex2b64:${hex2b64:${sha1:the quick brown fox}}
134 The base62 operator is actually a base36 operator in the Darwin and Cygwin
135 environments. Write cunning tests that produce the same output in both cases,
136 while doing a reasonable check.
139 {eq {${base62:12345}}{0003D7}}\
140 {eq {${base62:12345}}{0009IX}}\
143 {eq {${base62d:0003D7}}{12345}}\
144 {eq {${base62d:0009IX}}{12345}}\
147 {eq {${base62d:3D7}}{12345}}\
148 {eq {${base62d:9IX}}{12345}}\
150 base62 error: ${base62:12345x}
151 base62d error:${base62d:0003D7.}
153 hmac: ${hmac{md5}{somesecret}{mail.example.com 2002-10-17 11:30:59}}
154 hmac: ${hmac{sha1}{somesecret}{mail.example.com 2002-10-17 11:30:59}}
155 md5: ${md5:the quick brown fox jumps over the lazy dog}
158 mask: ${mask:192.168.10.206/28}
159 mask: ${mask:192.168.10.206/32}
160 mask: ${mask:192.168.10.206/33}
161 mask: ${mask:192.168.10.206/0}
162 mask: ${mask:192.168.10.206}
163 mask: ${mask:a.b.c.d}
164 nhash: ${nhash_24:monty} ${nhash_8_63:monty python}
165 lc/uc: ${lc:The Quick} ${uc: Brown Fox}
166 length: ${length_10:The quick brown fox} ${l_10:abc}
167 lclpt: ${local_part:local-part@dom.ain}
168 lclpt: ${local_part:Exim Person <local-part@dom.ain> (that's me)}
169 quote: ${quote:aZ09_.-Q} ${quote:ab*cd} ${quote:ab\cd"ef}
170 quote: ${quote:nl(\n)}
171 quote: ${quote:cr(\r)}
172 quote: ${quote:tab(\t)}
173 quote: ${quote:xff(\xff)}
174 quote: Empty>${quote:}<
175 quote_local_part: ${quote_local_part:abcd}
176 quote_local_part: ${quote_local_part:O'Reilly}
177 quote_local_part: ${quote_local_part:a space}
178 quote_local_part: ${quote_local_part:.something}
179 quote_local_part: ${quote_local_part:something.}
180 quote_local_part: ${quote_local_part:joe.bloggs}
181 quote_local_part: ${quote_local_part:a!b}
182 quote_local_part: ${quote_local_part:x@y}
183 quote_local_part: ${quote_local_part:ab*cd}
184 quote_local_part: ${quote_local_part:x:y}
185 quote_local_part: ${quote_local_part:ab\cd"ef}
186 quote_local_part: ${quote_local_part:}
187 rxquote:${rxquote:aZ09_,-Q} ${rxquote:ab*cd} ${rxquote:ab\cd"ef}
188 substr: ${substr_3_2:rhubarb} ${s_-5_2:1234567} ${s_-5_2:12} ${s_-3_2:12}
189 substr: ${s_3:rhubarb} ${s_-2:rhubarb}
191 substr: ${substr_10:abc}
192 str2b64:${str2b64:abcd}
193 str2b64:${str2b64:The quick brown \n fox}
196 strlen: ${strlen:abcdefgh}
197 time_eval: ${time_eval:10s}
198 time_eval: ${time_eval:2h}
199 time_eval: ${time_eval:1d5m}
200 time_eval: ${time_eval:1w2d3h4m5s}
201 time_eval: ${time_eval:14}
202 time_eval: ${time_eval:rhubarb}
203 time_interval: ${time_interval:0}
204 time_interval: ${time_interval:44}
205 time_interval: ${time_interval:999999}
206 time_interval: ${time_interval:-1}
207 time_interval: ${time_interval:rhubarb}
209 # stat is a bit tricky, but some of the fields of the aux-var directory
210 # should be the same on all systems
212 stat: ${extract{mode}{${stat:DIR/aux-var}}}
213 stat: ${extract{smode}{${stat:DIR/aux-var}}}
214 stat: ${stat:/a/non/existent/file}
216 # "Operators" that have expanded arguments
218 hash: ${hash{3}{monty}} ${hash{5}{monty}} ${hash{4}{62}{monty python}}
219 hash: ${hash{3}{abc}}X ${hash{3}{ab}}X ${hash{3}{a}}X ${hash{3}{}}X
220 nhash: ${nhash{24}{monty}} ${nhash{8}{63}{monty python}}
221 length: ${length{10}{The quick brown fox}} ${length{10}{abc}}
222 substr: ${substr{3}{2}{rhubarb}} ${substr{-5}{2}{1234567}} ${substr{-5}{2}{12}} ${substr{-3}{2}{12}}
223 substr: ${substr{${if eq{1}{1}{-8}}}{${if eq{1}{0}{25}{1}}}{abcde}}
228 ${hash{nonnumber}{abcd}}
229 ${hash{3}{2}{4}{abcd}}
230 ${substr{-3}{-2}{abcd}}
234 addrss: ${if eq {1}{2}{${address:invalid}}{NO}}
235 domain: ${if eq {1}{2}{${domain:invalid}}{NO}}
236 escape: ${if eq {1}{2}{${escape:invalid}}{NO}}
237 expand: ${if eq {1}{2}{\$primary_hostname ${expand:\$invalid}}{NO}}
238 hash: ${if eq {1}{2}{${hash_3:invalid}}{NO}}
239 md5: ${if eq {1}{2}{${md5:invalid}}{NO}}
240 mask: ${if eq {1}{2}{${mask:invalid}}{NO}}
242 # Number suffixes in conditions
243 1k: ${if >{1}{1k}{n}{y}}
244 1K: ${if >{1}{1K}{n}{y}}
245 1M: ${if >{1}{1M}{n}{y}}
246 1G: ${if >{1}{1G}{n}{y}}
249 # >32b should work, >64b not
251 4096M ${if >{1}{4096M}{y}{n}}
252 4096000000 ${if >{1}{4096000000}{y}{n}}
253 4611686018427387904 ${if >{1}{4611686018427387904} {y}{n}}
254 46116860184273879040 ${if >{1}{46116860184273879040}{y}{n}}
258 2=2: ${if ={2}{2}{y}{n}}
259 2==2: ${if =={2}{2}{y}{n}}
260 3=2: ${if ={3}{2}{y}{n}}
261 2==3: ${if =={2}{3}{y}{n}}
262 !2=2: ${if !={2}{2}{y}{n}}
263 !2==2: ${if !=={2}{2}{y}{n}}
264 !3=2: ${if !={3}{2}{y}{n}}
265 !2==3: ${if !=={2}{3}{y}{n}}
266 2>3: ${if >{2}{3}{y}{n}}
267 3>3: ${if >{3}{3}{y}{n}}
268 4>3: ${if >{4}{3}{y}{n}}
269 1>-1: ${if >{1}{-1}{y}{n}}
270 2>=3: ${if >={2}{3}{y}{n}}
271 3>=3: ${if >={3}{3}{y}{n}}
272 4>=3: ${if >={4}{3}{y}{n}}
273 2<3: ${if <{2}{3}{y}{n}}
274 3<3: ${if <{3}{3}{y}{n}}
275 4<3: ${if <{4}{3}{y}{n}}
276 2<=3: ${if <={2}{3}{y}{n}}
277 3<=3: ${if <={3}{3}{y}{n}}
278 4<=3: ${if <={4}{3}{y}{n}}
279 5<=3: ${if <={ 5 } { 3 } {y}{n}}
280 -3<=1: ${if <={-3}{1}{y}{n}}
282 5>3k: ${if >{5 } {3k }{y}{n}}
283 5>3m: ${if >{5 } {3m }{y}{n}}
284 5>3z: ${if >{5 } {3z }{y}{n}}
285 5>a: ${if >{ 5 } {a}{y}{n}}
287 >0: ${if > {}{0}{y}{n}}
288 =: ${if = {}{}{y}{n}}
289 -2<: ${if < {-2}{}{y}{n}}
290 08>07: ${if > {08}{07}{y}{n}}
291 011=11: ${if = {011}{11}{y}{n}}
293 def:y ${if def:tod_log{y}{n}}
294 def:n ${if def:host{y}{n}}
295 def:f ${if def:post{y}{n}}
296 def:h_f ${if def:h_xxx {y}{n}}
297 def:h_f ${if def:h_xxx:{y}{n}}
298 def:d: ${if def:tod_log:{y}{n}}
300 exists: ${if exists{/etc/passwd}{y}{n}}
301 exists: ${if exists{/doesnt}{y}{n}}
303 eq: ${if eq{abc}{abc}{y}{n}}
304 eq: ${if eq{abc}{xyz}{y}{n}}
305 !eq: ${if !eq{abc}{abc}{y}{n}}
306 !eq: ${if !eq{abc}{xyz}{y}{n}}
308 eqi: ${if eqi{abc}{abc}{y}{n}}
309 eqi: ${if eqi{abc}{ABC}{y}{n}}
310 eqi: ${if eqi{abc}{xyz}{y}{n}}
311 !eqi: ${if !eqi{abc}{abc}{y}{n}}
312 !eqi: ${if !eqi{abc}{aBc}{y}{n}}
313 !eqi: ${if !eqi{abc}{xyz}{y}{n}}
315 lt: ${if lt{ABC}{abc}{y}{n}}
316 lti: ${if lti{ABC}{abc}{y}{n}}
317 le: ${if le{ABC}{abc}{y}{n}}
318 lei: ${if lei{ABC}{abc}{y}{n}}
319 gt: ${if gt{ABC}{abc}{y}{n}}
320 gti: ${if gti{ABC}{abc}{y}{n}}
321 ge: ${if ge{ABC}{abc}{y}{n}}
322 gei: ${if gei{ABC}{abc}{y}{n}}
324 isip: ${if isip {1.2.3.4}{y}{n}} 1.2.3.4
325 isip4: ${if isip4{1.2.3.4}{y}{n}} 1.2.3.4
326 isip6: ${if isip6{1.2.3.4}{y}{n}} 1.2.3.4
327 isip: ${if isip {1:2:3:4}{y}{n}} 1:2:3:4
328 isip4: ${if isip4{1:2:3:4}{y}{n}} 1:2:3:4
329 isip6: ${if isip6{1:2:3:4}{y}{n}} 1:2:3:4
330 isip: ${if isip {::1}{y}{n}} ::1
331 isip4: ${if isip4{::1}{y}{n}} ::1
332 isip6: ${if isip6{::1}{y}{n}} ::1
333 isip: ${if isip {fe80::a00:20ff:fe86:a061}{y}{n}} fe80::a00:20ff:fe86:a061
334 isip4: ${if isip4{fe80::a00:20ff:fe86:a061}{y}{n}} fe80::a00:20ff:fe86:a061
335 isip6: ${if isip6{fe80::a00:20ff:fe86:a061}{y}{n}} fe80::a00:20ff:fe86:a061
336 isip: ${if isip {rhubarb}{y}{n}} rhubarb
337 isip4: ${if isip4{rhubarb}{y}{n}} rhubarb
338 isip6: ${if isip6{rhubarb}{y}{n}} rhubarb
340 match: ${if match{abcd}{\N^([ab]+)(\w+)$\N}{$2$1}fail}
341 match: ${if match{abcd}{^\N([ab]+)(\w+)$\N}{$2$1}fail}
342 match: ${if match{abcd}{^([ab]+)(\\w+)\$}{$2$1}fail}
343 match: ${if match{wxyz}{^([ab]+)(\\w+)\$}{$2$1}fail}
344 match: ${if match{abcd}{^([ab]+)(\\w+)\$}{$2[${if match{xyz}{(.*)}{$1}fail}]$1}fail}
346 match_domain: ${if match_domain{a.b.c}{x.y.z:a.b.c:p.q.r}{yes}{no}}
347 match_domain: ${if match_domain{a.b.c}{x.y.z:p.q.r}{yes}{no}}
348 match_domain: ${if match_domain{5.aa.bb}{+dlist}{yes}{no}}
349 match_domain: ${if match_domain{xxxyz}{+dlist}{yes}{no}}
350 match_domain: ${if match_domain{xyz}{+dlist}{yes}{no}}
352 ${if match{x@zz.aa.bb}{^(.*)} \
355 ${if match_domain{${domain:$1}}{+dlist}{[$1]}} \
360 ${if match{x@xxxabc}{^(.*)} \
363 ${if match_domain{${domain:$1}}{^\Nxxx(.*)\N}{[$1]}} \
368 match_address: ${if match_address{x@y.z}{p@q:*@y.z}{yes}{no}}
369 match_address: ${if match_address{x@y.z}{p@q:x@*.z}{yes}{no}}
371 match_local_part:${if match_local_part{jo}{jack:jill:jo:john}{yes}{no}}
372 match_local_part:${if match_local_part{jo}{\N^\w\N}{yes}{no}}
374 match_ip: 01 ${if match_ip{1.2.3.4}{4.5.6.7:1.2.3.4}}
375 match_ip: 02 ${if match_ip{1.2.3.4}{4.5.6.7:1.2.3.6}}
376 match_ip: 03 ${if match_ip{1.2.3.4}{4.5.6.7:1.2.3.6/24}}
377 match_ip: 04 ${if match_ip{1.2.3.4}{4.5.6.7:1.2.3.6:*}}
378 match_ip: 05 ${if match_ip{1.2.3.4}{4.5.6.7:1.2.3.6:name}}
379 match_ip: 06 ${if match_ip{1.2.3.4}{:4.5.6.7}}
380 match_ip: 07 ${if match_ip{}{:4.5.6.7}}
381 match_ip: 08 ${if match_ip{V4NET.11.12.13}{+hlist}}
382 match_ip: 09 ${if match_ip{V4NET.11.12.14}{+hlist}}
383 match_ip: 10 ${if match_ip{192.168.3.4}{+hlist}}
384 match_ip: 11 ${if match_ip{somename}{+hlist}}
385 match_ip: 12 ${if match_ip{1.2.3.4}{lsearch;DIR/aux-fixed/0002.matchip}}
386 match_ip: 13 ${if match_ip{1.2.3.4}{net-lsearch;DIR/aux-fixed/0002.matchip}}
387 match_ip: 14 ${if match_ip{5.6.7.8}{net24-lsearch;DIR/aux-fixed/0002.matchip}}
388 match_ip: 15 ${if match_ip{abcd::dcba}{net-iplsearch;DIR/aux-fixed/0002.matchip}}
390 queue_running: ${if queue_running{y}{n}}
391 first_delivery: ${if first_delivery{y}{n}}
393 queue_running after or: ${if or{{eq {0}{0}}{queue_running}}{y}{n}}
394 first_delivery after or: ${if or{{eq {0}{0}}{first_delivery}}{y}{n}}
396 # Default values for both if strings
398 \${if eq{1}{1}} >${if eq{1}{1}}<
399 \${if eq{1}{2}} >${if eq{1}{2}}<
401 # Lookups: DIR is the testing directory. In this test we can only use the
402 # lookups that are required in all cases.
404 ${lookup{postmaster}lsearch{DIR/aux-fixed/0002.aliases}{$value}fail}
406 ${lookup{x@y}lsearch*@{DIR/aux-fixed/0002.starat}{$value}fail}
407 ${lookup{x@z}lsearch*{DIR/aux-fixed/0002.starat}{$value}fail}
408 ${lookup{x@z}lsearch*@{DIR/aux-fixed/0002.starat}{$value}fail}
409 ${lookup{x@w}lsearch*@{DIR/aux-fixed/0002.starat}{$value}fail}
411 ${lookup{a.b.c.d}partial-lsearch{DIR/aux-fixed/0002.domains}{$value}fail}
412 ${lookup{x.y.z}partial-lsearch{DIR/aux-fixed/0002.domains}{$value}{failed x.y.z}}
413 ${lookup{p.q}partial-lsearch{DIR/aux-fixed/0002.domains}{$value}fail}
414 ${lookup{o.p.q}partial-lsearch{DIR/aux-fixed/0002.domains}{$value}fail}
415 ${lookup{m.n.o.p.q}partial-lsearch{DIR/aux-fixed/0002.domains}{$value}fail}
416 ${lookup{x.y.z}partial1-lsearch{DIR/aux-fixed/0002.domains}{$value}fail}
417 ${lookup{x.y.z}partial0-lsearch{DIR/aux-fixed/0002.domains}{$value}fail}
419 q1: ${lookup{abc}lsearch{DIR/aux-fixed/0002.quoted}}
420 q2: ${lookup{xyz}lsearch{DIR/aux-fixed/0002.quoted}}
421 q3: ${lookup{pqr}lsearch{DIR/aux-fixed/0002.quoted}}
422 q4: ${lookup{a:b}lsearch{DIR/aux-fixed/0002.quoted}}
423 q5: ${lookup{"quoted"}lsearch{DIR/aux-fixed/0002.quoted}}
424 q6: ${lookup{white space}lsearch{DIR/aux-fixed/0002.quoted}}
425 q7: ${lookup{b\\s}lsearch{DIR/aux-fixed/0002.quoted}}
427 abc: ${lookup{abc}wildlsearch{DIR/aux-var/0002.wild}}
428 a.b.c: ${lookup{a.b.c}wildlsearch{DIR/aux-var/0002.wild}}
429 ab.c: ${lookup{ab.c}wildlsearch{DIR/aux-var/0002.wild}}
430 xyz: ${lookup{xyz}wildlsearch{DIR/aux-var/0002.wild}}
431 Xyz: ${lookup{Xyz}wildlsearch{DIR/aux-var/0002.wild}}
432 Zyz: ${lookup{Zyz}wildlsearch{DIR/aux-var/0002.wild}}
433 a b: ${lookup{a b}wildlsearch{DIR/aux-var/0002.wild}}
434 a b: ${lookup{a b}wildlsearch{DIR/aux-var/0002.wild}}
435 a:b: ${lookup{a:b}wildlsearch{DIR/aux-var/0002.wild}}
436 a.b: ${lookup{a.b}wildlsearch{DIR/aux-var/0002.wild}}
437 a..b: ${lookup{a..b}wildlsearch{DIR/aux-var/0002.wild}}
438 a9b: ${lookup{a9b}wildlsearch{DIR/aux-var/0002.wild}}
439 a99b: ${lookup{a99b}wildlsearch{DIR/aux-var/0002.wild}}
441 # Should give the same results as above because expansion does nothing
443 abc: ${lookup{abc}nwildlsearch{DIR/aux-var/0002.wild}}
444 a.b.c: ${lookup{a.b.c}nwildlsearch{DIR/aux-var/0002.wild}}
445 ab.c: ${lookup{ab.c}nwildlsearch{DIR/aux-var/0002.wild}}
446 xyz: ${lookup{xyz}nwildlsearch{DIR/aux-var/0002.wild}}
447 Xyz: ${lookup{Xyz}nwildlsearch{DIR/aux-var/0002.wild}}
448 Zyz: ${lookup{Zyz}nwildlsearch{DIR/aux-var/0002.wild}}
449 a b: ${lookup{a b}nwildlsearch{DIR/aux-var/0002.wild}}
450 a b: ${lookup{a b}nwildlsearch{DIR/aux-var/0002.wild}}
451 a:b: ${lookup{a:b}nwildlsearch{DIR/aux-var/0002.wild}}
453 # Should fail because of no expansion
455 a.b: ${lookup{a.b}nwildlsearch{DIR/aux-var/0002.wild}{$value}{NO}}
456 a..b: ${lookup{a..b}nwildlsearch{DIR/aux-var/0002.wild}{$value}{NO}}
457 a9b: ${lookup{a9b}nwildlsearch{DIR/aux-var/0002.wild}{$value}{NO}}
458 a99b: ${lookup{a99b}nwildlsearch{DIR/aux-var/0002.wild}{$value}{NO}}
460 # But these should succeed
462 a\\:b: ${lookup{a\\:b}nwildlsearch{DIR/aux-var/0002.wild}}
463 a\\:Xb: ${lookup{a\\:Xb}nwildlsearch{DIR/aux-var/0002.wild}}
465 # Some tests of case-(in)dependence
467 MiXeD-CD: ${lookup{MiXeD-CD}nwildlsearch{DIR/aux-var/0002.wild}{$value}{NOT FOUND}}
468 MixeD-CD: ${lookup{MixeD-CD}nwildlsearch{DIR/aux-var/0002.wild}{$value}{NOT FOUND}}
469 MiXeD-Ncd: ${lookup{MiXeD-Ncd}nwildlsearch{DIR/aux-var/0002.wild}{$value}{NOT FOUND}}
470 MixeD-Ncd: ${lookup{MixeD-Ncd}nwildlsearch{DIR/aux-var/0002.wild}{$value}{NOT FOUND}}
472 # IP address (CIDR) lookups
474 1.2.3.4: ${lookup{1.2.3.4}iplsearch{DIR/aux-fixed/0002.iplsearch}}
475 1.2.3.5: ${lookup{1.2.3.5}iplsearch{DIR/aux-fixed/0002.iplsearch}}
476 1.2.3.5: ${lookup{1.2.3.5}iplsearch*{DIR/aux-fixed/0002.iplsearch}}
477 abcd::cdab: ${lookup{abcd::cdab}iplsearch{DIR/aux-fixed/0002.iplsearch}}
478 192.168.1.2: ${lookup{192.168.1.2}iplsearch{DIR/aux-fixed/0002.iplsearch}}
479 192.168.5.6: ${lookup{192.168.5.6}iplsearch{DIR/aux-fixed/0002.iplsearch}}
480 abcd:abcd:: ${lookup{abcd:abcd::}iplsearch{DIR/aux-fixed/0002.iplsearch}}
481 abcd:abcd:1:: ${lookup{abcd:abcd:1::}iplsearch{DIR/aux-fixed/0002.iplsearch}}
482 abcd:abcd::3 ${lookup{abcd:abcd::3}iplsearch{DIR/aux-fixed/0002.iplsearch}}
483 rhubarb ${lookup{rhubarb}iplsearch{DIR/aux-fixed/0002.iplsearch}}
486 # Nested Lookups - style 1
488 ${lookup{${lookup{key1}lsearch{DIR/aux-fixed/0002.rec}{$value}{key1f}}}lsearch{DIR/aux-fixed/0002.rec}{$value}fail}
489 ${lookup{${lookup{key3}lsearch{DIR/aux-fixed/0002.rec}{$value}{key1f}}}lsearch{DIR/aux-fixed/0002.rec}{$value}fail}
491 # Nested Lookups - style 2
493 ${lookup{key1}lsearch{DIR/aux-fixed/0002.rec}{${lookup{$value}lsearch{DIR/aux-fixed/0002.rec}{$value}{failed for $value}}}{failed for key1}}
494 ${lookup{key3}lsearch{DIR/aux-fixed/0002.rec}{${lookup{$value}lsearch{DIR/aux-fixed/0002.rec}{$value}{failed for $value}}}{failed for key1}}
496 # Other nesting tests
498 ${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}}}
499 ${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}}}
500 ${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}}}
501 ${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}}}
503 # Lookup quotes for standardly expected lookups
505 lsearch ${quote_lsearch: !@#\$%^&*()_-+=|\\~`1234567890\{[\}]qwertyuiop:;"'asdfghjkl<,>.?/zxcvbnm}
506 xxx ${quote_xxx: !@#\$%^&*()_-+=|\\~`1234567890\{[\}]qwertyuiop:;"'asdfghjkl<,>.?/zxcvbnm}
510 ${extract{B}{A=1 B=2 C=3}}
511 ${extract{ B }{A=1 B=2 C=3}{$value}{NOT FOUND}}
512 ${extract{2}{:}{1:2:3}}
513 ${extract{ 2 }{:}{1:2:3}{$value}{NOT FOUND}}
514 Empty:<${extract{D}{A=1 B=2 C=3}}>
515 Empty:<${extract{4}{:}{1:2:3}}>
516 ${extract{C}{A=1 B=2 C=3}{<$value>}}
517 ${extract{3}{:}{1:2:3}{<$value>}}
518 Empty:<${extract{Z}{A=1 B=2 C=3}{<$value>}}>
519 Empty:<${extract{4}{:}{1:2:3}{<$value>}}>
520 ${extract{Z}{A=1 B=2 C=3}{<$value>}{no Z}}
521 ${extract{4}{:}{1:2:3}{<$value>}{no 4}}
522 ${extract{Z}{A=1 B=2 C=3}{<$value>}fail}
523 ${extract{4}{:}{1:2:3}{<$value>}fail}
524 ${extract{K4}{${sg{1=A 4=D 3=C}{(\\d+)=}{K\$1=}}}}
525 ${extract{0}{:}{a:b:c:d:e}{$value}{FAIL}}
526 ${extract{1}{:}{a:b:c:d:e}{$value}{FAIL}}
527 ${extract{-1}{:}{a:b:c:d:e}{$value}{FAIL}}
528 ${extract{-5}{:}{a:b:c:d:e}{$value}{FAIL}}
529 ${extract{-6}{:}{a:b:c:d:e}{$value}{FAIL}}
530 ${extract{-3}{:,}{a,,b::c}}
531 ${extract{2}{:,}{a,,b::c}}
532 ${extract{3}{:,}{a,,b::c}}
533 ${extract{a-b}{X = "one two" a-b "three four" 5=99}}
536 ${extract{ 2 }{ }{a b c}}
540 abcdea aaa xyz ${tr{abcdea}{aaa}{xyz}}
541 abcdea a z ${tr{abcdea}{a}{z}}
542 abcdea a ${tr{abcdea}{a}{}}
543 abcdea abc z ${tr{abcdea}{abc}{z}}
546 "TrUe" ${if bool{TrUe}{true}{false}} EXPECT: true
547 "FALSE" ${if bool{FALSE}{true}{false}} EXPECT: false
548 " yes" ${if bool{ yes}{true}{false}} EXPECT: true
549 " no" ${if bool{ no}{true}{false}} EXPECT: false
550 "yes " ${if bool{yes }{true}{false}} EXPECT: true
551 "-1" ${if bool{-1}{true}{false}} EXPECT: error
552 "0" ${if bool{0}{true}{false}} EXPECT: false
553 "1" ${if bool{1}{true}{false}} EXPECT: true
554 " 0 " ${if bool{ 0 }{true}{false}} EXPECT: false
555 " 1 " ${if bool{ 1 }{true}{false}} EXPECT: true
556 "1111111111111111111" ${if bool{1111111111111111111}{true}{false}} EXPECT: true
557 "9" ${if bool{9}{true}{false}} EXPECT: true
558 " " ${if bool{ }{true}{false}} EXPECT: false
559 "text" ${if bool{text}{true}{false}} EXPECT: error
560 " text" ${if bool{ text}{true}{false}} EXPECT: error
561 "text " ${if bool{text }{true}{false}} EXPECT: error
562 " text " ${if bool{ text }{true}{false}} EXPECT: error
563 "00" ${if bool{00}{true}{false}} EXPECT: false
564 "!true" ${if !bool{true}{true}{false}} EXPECT: false
565 "!false" ${if !bool{false}{true}{false}} EXPECT: true
567 "TrUe" ${if bool_lax{TrUe}{true}{false}} EXPECT: true
568 "FALSE" ${if bool_lax{FALSE}{true}{false}} EXPECT: false
569 " yes" ${if bool_lax{ yes}{true}{false}} EXPECT: true
570 " no" ${if bool_lax{ no}{true}{false}} EXPECT: false
571 "yes " ${if bool_lax{yes }{true}{false}} EXPECT: true
572 "-1" ${if bool_lax{-1}{true}{false}} EXPECT: true
573 "0" ${if bool_lax{0}{true}{false}} EXPECT: false
574 "1" ${if bool_lax{1}{true}{false}} EXPECT: true
575 " 0 " ${if bool_lax{ 0 }{true}{false}} EXPECT: false
576 " 1 " ${if bool_lax{ 1 }{true}{false}} EXPECT: true
577 "1111111111111111111" ${if bool_lax{1111111111111111111}{true}{false}} EXPECT: true
578 "9" ${if bool_lax{9}{true}{false}} EXPECT: true
579 " " ${if bool_lax{ }{true}{false}} EXPECT: false
580 "text" ${if bool_lax{text}{true}{false}} EXPECT: true
581 " text" ${if bool_lax{ text}{true}{false}} EXPECT: true
582 "text " ${if bool_lax{text }{true}{false}} EXPECT: true
583 " text " ${if bool_lax{ text }{true}{false}} EXPECT: true
584 "00" ${if bool_lax{00}{true}{false}} EXPECT: true
585 "!true" ${if !bool_lax{true}{true}{false}} EXPECT: false
586 "!false" ${if !bool_lax{false}{true}{false}} EXPECT: true
591 <:abcd:> ${rfc2047:<:abcd:>}
592 <:ab cd:> ${rfc2047:<:ab cd:>}
593 Long: ${rfc2047: here we go: a string that is going to be encoded: it will go over the 75-char limit}
594 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}
598 ${rfc2047d:abcd abcd}
599 ${rfc2047d:<:abcd:> =?iso-8859-8?Q?=3C=3Aabcd=3A=3E?=}
600 ${rfc2047d:<:ab cd:> =?iso-8859-8?Q?=3C=3Aab_cd=3A=3E?=}
601 ${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?=}
602 ${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?=}
606 abcd ${from_utf8:abcd}
607 aÀÿd ${from_utf8:aÃ
\80ÿd}
608 toobig ${from_utf8:aĀd}
612 \${sg{abcdefabcdef}{abc}{xyz}} =${sg{abcdefabcdef}{abc}{xyz}}
613 \${sg{ab:xy::z}{:}{::}} =${sg{ab:xy::z}{:}{::}}
614 \${sg{abcdefabcdef}{(..)[^c]}{>\$1<}} =${sg{abcdefabcdef}{(..)[^c]}{>$1<}}
615 \${sg{abcdefabcdef}{(..)[^c]}{>\\\$1<}} =${sg{abcdefabcdef}{(..)[^c]}{>\$1<}}
616 \${sg{abcdefabcdef}{(..)[^c]}{>\\N\$1\\N<}}=${sg{abcdefabcdef}{(..)[^c]}{>\N$1\N<}}
617 \${sg{abbab}{a*}{+}} =${sg{abbab}{a*}{+}}
622 ${readfile{DIR/aux-fixed/0002.readfile}}
623 ${readfile{DIR/aux-fixed/0002.readfile}{}}
624 ${readfile{DIR/aux-fixed/0002.readfile}{:}}
625 ${readfile{DIR/aux-fixed/0002.readfile}{ - }}
626 ${readfile{/non/exist/file}}
627 ${if exists{/non/exist/file}{${readfile{/non/exist/file}}}{non-exist}}
628 >${readfile{DIR/aux-fixed/0002.readfile}{!}}\
633 ${run{DIR/aux-fixed/0002.runfile 0}}
635 ${run{DIR/aux-fixed/0002.runfile 0}{1}{2}}
637 ${run{DIR/aux-fixed/0002.runfile 0}{$value}{2}}
639 ${run{DIR/aux-fixed/0002.runfile 1}{$value}{2}}
641 ${run{DIR/aux-fixed/0002.runfile 1}{$value}{$value}}
643 ${run{DIR/test-nonexist}{Y}{N}}
645 >>${run{DIR/bin/iefbr14}}<<
647 ${if eq{1}{2}{${run{/non/exist}}}{1!=2}}
652 ${prvs{userx@test.ex}{secret}}
653 ${prvs{userx@test.ex}{secret}{1}}
654 ${prvs{userx@test.ex}{secret}{8}}
658 ${prvs{userx@test.ex}{secret}{12}}
659 ${prvs{userx@test.ex}{secret}{rhubarb}}
660 ${prvs{userx@test.ex}{secret}{}}
662 # Correct checks; can't put explicit addresses in the tests, because they
663 # will change over time.
665 ${prvscheck{${prvs{userx@test.ex}{secret}}}{secret}}
666 result=$prvscheck_result
668 ${prvscheck{${prvs{userx@test.ex}{secret}{1}}}{secret}\
669 {>$prvscheck_result< >$prvscheck_address< >$prvscheck_keynum<}}
670 result=$prvscheck_result
672 ${prvscheck{${prvs{userx@test.ex}{secret}{8}}}{secret}{}}
673 result=$prvscheck_result
677 ${prvscheck{${prvs{userx@test.ex}{secret}}}{socrot}}
678 result=$prvscheck_result
680 ${prvscheck{${prvs{userx@test.ex}{secret}}}{socrot}{$prvscheck_keynum}}
681 result=$prvscheck_result
685 >>${prvscheck{userx@test.ex}{secret}}<<
686 result=$prvscheck_result
693 ${expand:abcd${tod_log}
695 ${if and {xyz}{a}{b}}
696 ${if and {{xya}}{a}{b}}
697 ${if and {{${lookup{x}lsearch{/a/b}}}}{a}{b}}
698 ${if eq {$h_xyz}{1}{y}{n}}
699 ${if eq {$h_xyz:}{1}{y}{n}
700 ${if def:h_xyz}{y}{n}}
701 ${if or {eq {}{}{yes}{no}}
702 ${if or {{eq {}{}{yes}{no}}
703 ${if or {{eq {}{}}{yes}{no}}
707 # Iterations: forany and forall
709 ${if forany{a:b:c}{eq{$item}{a}}{yes}{no}}
710 ${if forany{a:b:c}{eq{$item}{b}}{yes}{no}}
711 ${if forany{a:b:c}{eq{$item}{c}}{yes}{no}}
712 ${if forany {a:b:c} {eq {$item} {z}} {yes} {no}}
713 ${if !forany{a:b:c}{eq{$item}{z}}{yes}{no}}
714 ${if !forany{a:b:c}{eq{$item}{a}}{yes}{no}}
715 ${if forany{}{eq{$item}{a}}{yes}{no}}
716 ${if !forany{}{eq{$item}{a}}{yes}{no}}
717 ${if forany{<, $primary_hostname,foo,bar}{eq{$item}{$primary_hostname}}{yes}{no}}
719 ${if forany{}{yes}{no}}
720 ${if forany{a:b:c}{gt{$item}{a}{yes}{no}}
722 ${if forall{a:b:c}{match{$item}{^[a-c]\$}}{yes}{no}}
723 ${if forall{q:b:c}{match{$item}{^[a-c]\$}}{yes}{no}}
724 ${if forall{a:b:z}{match{$item}{^[a-c]\$}}{yes}{no}}
725 ${if forall{}{match{$item}{^[a-c]\$}}{yes}{no}}
727 ${if !forall{a:b:c}{match{$item}{^[a-c]\$}}{yes}{no}}
728 ${if !forall{q:b:c}{match{$item}{^[a-c]\$}}{yes}{no}}
729 ${if !forall{a:b:z}{match{$item}{^[a-c]\$}}{yes}{no}}
730 ${if !forall{}{match{$item}{^[a-c]\$}}{yes}{no}}
736 {$item: ${if forall{x:y:z}{match{$item}{^[x-z]\$}}{true}{false}}}\
739 {outer=yes}{outer=no}} item='$item' (unset)
745 {$item: ${if !forall{x:y:z}{match{$item}{^[x-z]\$}}{true}{false}}}\
748 {outer=yes}{outer=no}}
750 # Error inside nest - check message is helpful
754 {$item: ${if forall{x:y:z}{match{$item}{^[x-z]\$}{true}{false}}}\
757 {outer=yes}{outer=no}}
760 # Miscellaneous (for bug fixes, etc)
762 ${if ={1}{1} {true}{${if ={1}{1} {true}{${if ={1}{1}{true}fail}}}}}
765 # Test "escape" with print_topbitchars
766 exim -be -DPTBC=print_topbitchars
767 escape: ${escape:B7·F2ò}
769 # Checkout expansion debugging
770 exim -d-all+expand -be
771 primary_hostname: $primary_hostname
772 match: ${if match{abcd}{\N^([ab]+)(\w+)$\N}{$2$1}fail}
773 match: ${if match{wxyz}{\N^([ab]+)(\w+)$\N}{$2$1}fail}
774 ${if eq {1}{1}{yes}{${lookup{xx}lsearch{/non/exist}}}}
775 match_address: ${if match_address{a.b.c}{a.b.c}{yes}{no}}
777 # Sender host name and address etc, all unset
779 -oMa sender_host_address = $sender_host_address
780 sender_host_port = $sender_host_port
781 -oMaa sender_host_authenticated = $sender_host_authenticated
782 -oMai authenticated_id = $authenticated_id
783 -oMas authenticated_sender = $authenticated_sender
784 -oMi interface_address = $interface_address
785 interface_port = $interface_port
786 -oMr received_protocol = $received_protocol
787 -oMs sender_host_name = $sender_host_name
788 -oMt sender_ident = $sender_ident
790 # Sender host name and address etc, all set except host name.
791 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
792 -oMa sender_host_address = $sender_host_address
793 sender_host_port = $sender_host_port
794 -oMaa sender_host_authenticated = $sender_host_authenticated
795 -oMai authenticated_id = $authenticated_id
796 -oMas authenticated_sender = $authenticated_sender
797 -oMi interface_address = $interface_address
798 interface_port = $interface_port
799 -oMr received_protocol = $received_protocol
800 -oMt sender_ident = $sender_ident
802 # Sender host name explicitly set
803 exim -be -oMa V4NET.0.0.1.1234 -oMs my.host.name
804 -oMa sender_host_address = $sender_host_address
805 sender_host_port = $sender_host_port
806 -oMs sender_host_name = $sender_host_name
808 # Sender host name lookup fails (V4NET.11.12.13 is not reverse registered)
809 exim -be -oMa V4NET.11.12.13
810 -oMs sender_host_name = $sender_host_name
811 host_lookup_failed = $host_lookup_failed
813 # Sender host name and protocol set by Sendmail-compatible option
814 exim -be -pspecial:host.name
815 -p received_protocol = $received_protocol
816 -p sender_host_name = $sender_host_name
818 # Sender host name and address etc, all set except host name,
819 # which should therefore be looked up from the address, but not if
820 # we are skipping. The debug output for this test will show when
822 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
823 -oMa sender_host_address = $sender_host_address
824 sender_host_port = $sender_host_port
825 -oMaa sender_host_authenticated = $sender_host_authenticated
826 -oMai authenticated_id = $authenticated_id
827 -oMas authenticated_sender = $authenticated_sender
828 -oMi interface_address = $interface_address
829 interface_port = $interface_port
830 -oMr received_protocol = $received_protocol
831 ----> No lookup yet: ${if eq{black}{white}{$sender_host_name}{No}}
832 -oMs sender_host_name = $sender_host_name
833 -oMt sender_ident = $sender_ident
835 # Test no auto host name lookup for query-style lookups
836 exim -d -bh V4NET.0.0.1
838 exim -d -bh V4NET.0.0.2
840 # Test $reply_address
870 # Check RFC 2047 decoding with (default) length check
875 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?=
879 # Check RFC 2047 decoding with length check disabled
880 exim -DLENCHECK=check_rfc2047_length=false -bh V4NET.0.0.0
884 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?=
888 # Certain kind of error
890 match_ip: 15 ${if match_ip{1.2.3.4}{1.2.3}}
891 match_ip: 16 ${if match_ip{1.2.3.4}{1.2.3.4/abc}}