String expansions: fix ${extract }, for the numeric/3-string case. Bug 1807
[exim.git] / test / scripts / 0000-Basic / 0002
CommitLineData
59371ea7
PH
1# Common string expansions
2#
3# This is the main string expansion test that tests those expansions that will
4# be present in the basic Exim binary which we require in order to run these
5# tests at all. Specialized expansion tests also exist for optional features
6# in other test scripts.
c9a55f6a 7munge dnssec
59371ea7
PH
8
9exim -be
10
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.
14
15# Some fixed variables
16
17exim_path: $exim_path
71224040 18exim_version: $exim_version
98b8312f
HSHR
19config_dir: $config_dir
20config_file: $config_file
59371ea7
PH
21primary_hostname: $primary_hostname
22primary_hostname: ${primary_hostname}
23qualify_domain: $qualify_domain
24bounce_return_size_limit: ${bounce_return_size_limit}
25spool_directory: $spool_directory
26unknown: ${unknown}
27h_subject: $h_subject:(should be empty)
28h_subject:$h_subject (should be empty)
29header in curlies: ${header_subject:} (should fail)
30
31# \$message_headers should be empty
32message_headers: >$message_headers<
33
34# Continuation
35x\
36y
37x\
38 y
39
40# Overlong names and overbig numbers
41
42+$aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
43+${aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}
44+$11111111111111111111111111111111111
45+${11111111111111111111111111111111111}
46
29f89cad
PH
47# List operations
48
49filter: "${filter{a:b:c}{eq{1}{1}}}"
50filter: ${filter{a:b:c}{!eq{$item}{b}}}
51filter: ${filter{<' a'b'c}{!eq{$item}{b}}}
52filter: ${filter{<' ''a'b' ''c}{!eq{$item}{b}}}
53filter: "${filter{}{!eq{$item}{b}}}"
54
55map: "${map{}{$item}}"
56map: ${map{a:b:c}{$item}}
57map: ${map{a:b:c}{:$item:}}
58map: ${if eq{1}{0}{${map{a:b:c}{:$item:}}}{fail string}}
59map: ${map{:b:c}{[$item]}}
60
61reduce: "${reduce{}{+}{$value$item}}"
62reduce: ${reduce{a:b:c}{+}{$value$item}}
63reduce: ${reduce {<, 1,2,3}{0}{${eval:$value+$item}}}
64reduce: ${reduce {3:0:9:4:6}{0}{${if >{$item}{$value}{$item}{$value}}}}
65
a64a3dfa
JH
66listnamed: ${listnamed:dlist}
67listnamed: ${listnamed:+dlist}
68listnamed: ${listnamed:hlist}
69listnamed: ${listnamed:elist}
70listnamed: ${listnamed:flist}
71listnamed: ${listnamed:nolist}
72listnamed: ${listnamed_d:dlist}
73listnamed: ${listnamed_d:hlist}
74listnamed: ${listnamed_z:dlist}
75
76listcount: ${listcount:a:b:c}
77listcount: ${listcount:}
78listcount: ${listcount:<;a;b;c}
79listcount: ${listcount:${listnamed:dlist}}
042eb971 80
aa26e137
JH
81listextract: ${listextract{ 2}{a:b:c:d}}
82listextract: ${listextract{-2}{<,a,b,c,d}{X${value}X}}
83listextract: ${listextract{ 5}{a:b:c:d}}
84listextract: ${listextract{-5}{a:b:c:d}}
85listextract: ${listextract{ 5}{a:b:c:d}{}{fail}}
86listextract: ${listextract{ 5}{a:b:c:d}{}fail}
87
ac4ef9bd
JH
88sort: ${sort{3:2:1:4}{<}{$item}}
89sort: ${sort {<, 3,2,1,4}{>}{$item}}
90sort: ${sort{c:B:a:aa}{lti}{$item}}
91sort: ${sort{666 r99.ex.com:10 smtp.ex.com:100 r2.ex.com}{<}{${sg {$item}{([0-9]*).*\$}{\$1}}}}
92sort: ${sort{666,r99.ex.com:10,smtp.ex.com:100,r2.ex.com}{<}{${listextract{1}{<,$item}}}}
93sort: "${sort{}{<}{$item}}"
94
ec95d1a6
PH
95# Tests with iscntrl() and illegal separators
96
97map: ${map{<\n a\n\nb\nc}{'$item'}}
98
99reduce: ${reduce {<n 1\n2\n3}{0}{${eval:$value+$item}}}
100reduce: ${reduce {<\n 1\n2\n3}{0}{${eval:$value+$item}}}
101reduce: ${reduce { <\n 1\n 2 \n 3 }{0}{${eval:$value+$item}}}
102reduce: ${reduce {<\x7f 1\x7f2\177 3}{0}{${eval:$value+$item}}}
103
59371ea7
PH
104# Operators
105
723c72e6
JH
106acl: ${acl
107acl: ${acl}
bef3ea7f 108acl: ${acl {a_nosuch}}
723c72e6
JH
109acl: ${acl {a_ret}}
110acl: ${acl {a_ret}{person@dom.ain}}
525239c1
JH
111acl: ${acl {a_ret}{firstarg}{secondarg}}
112acl: ${acl {a_ret}{arg with spaces}}
723c72e6
JH
113acl: ${acl {a_none}}
114acl: ${acl {a_none}{person@dom.ain}}
115acl: ${acl {a_deny}}
116acl: ${acl {a_deny}{person@dom.ain}}
bef3ea7f
JH
117acl: ${acl {a_defer}}
118acl: ${acl {a_sub}{top_arg_1}{top_arg_2}{top_arg_3}}
723c72e6
JH
119acl: ${reduce {1:2:3:4} {} {$value ${acl {a_ret}{$item}}}}
120
59371ea7
PH
121addrss: ${address:local-part@dom.ain}
122addrss: ${address:Exim Person <local-part@dom.ain> (that's me)}
123domain: ${domain:local-part@dom.ain}
124domain: ${domain:Exim Person <local-part@dom.ain> (that's me)}
29f89cad
PH
125
126addresses: ${addresses:>' 'abc@xyz, 'pqr@xyz}
127addresses: ${addresses:Exim Person <local-part@dom.ain> (that's me)}
128addresses: ${addresses:>+ Exim Person <local-part@dom.ain> (that's me),\
129 xyz@abc}
130addresses: ${addresses:Exim Person <local-part@dom.ain> (that's me), \
131 xyz@abc, nullgroupname:;, group: p@q, r@s; }
132addresses: ${addresses:local-part@dom.ain <local-part@dom.ain>}
133
59371ea7
PH
134escape: ${escape:B7F2}
135eval: ${eval:1+1}
136eval: ${eval:1+2*3}
137eval: ${eval:(1+2)*3}
138eval: ${eval:3/2*4}
139eval: ${eval:3*4/2}
140eval: ${eval:42}
141eval: ${eval:}
142eval: ${eval:-2}
143eval: ${eval:-2 - -3}
144eval: ${eval:-2 - (-3)}
145eval: ${eval:-2 - (-3}
146eval: ${eval:-2 - -3)}
147eval: ${eval:-2 --3}
148eval: ${eval:-2 -+3}
149eval: ${eval:-2 -+-3}
150eval: ${eval:(2*(1+1))/2 + 40K}
151eval: ${eval:077}
152eval: ${eval:08}
153eval10: ${eval10:077}
154eval10: ${eval10:08}
af561417
PH
155eval10: ${eval10:0x1234}
156eval: ${eval:2+42%5}
0ce9abe6
PH
157eval: ${eval:0xc&5}
158eval: ${eval:0xc & 5 }
159eval: ${eval:0x0c|5}
160eval: ${eval:0xc^5}
161eval: ${eval:0xc>>1}
162eval: ${eval:0xc >> 2}
163eval: ${eval:0xc >> 4 }
164eval: ${eval:0xc<<1}
165eval: ${eval:~255&0x1234}
166eval: ${eval:~ 255&0x1234}
167eval: ${eval: -(~255&0x1234)}
af561417 168
59371ea7
PH
169expand: \$primary_hostname ${expand:\$primary_hostname}
170hash: ${hash_3:monty} ${hash_5:monty} ${hash_4_62:monty python}
171hash: ${hash_3:abc}X ${hash_3:ab}X ${hash_3:a}X ${hash_3:}X
172hex2b64:${hex2b64:12345678}
173hex2b64:${hex2b64:abcdef}
174hex2b64:${hex2b64:ABCDEF}
175hex2b64:${hex2b64:1a2b3c4d5e6f}
176hex2b64:${hex2b64:1a2b3c4d5e6}
177hex2b64:${hex2b64:1a2b3c4d5e6g}
178hex2b64:${hex2b64:${md5:the quick brown fox}}
179hex2b64:${hex2b64:${sha1:the quick brown fox}}
180
181The base62 operator is actually a base36 operator in the Darwin and Cygwin
182environments. Write cunning tests that produce the same output in both cases,
183while doing a reasonable check.
184
185base62: ${if or {\
186 {eq {${base62:12345}}{0003D7}}\
187 {eq {${base62:12345}}{0009IX}}\
0ce9abe6 188 }{OK}{NOT OK}}
59371ea7
PH
189base62d: ${if or {\
190 {eq {${base62d:0003D7}}{12345}}\
191 {eq {${base62d:0009IX}}{12345}}\
0ce9abe6 192 }{OK}{NOT OK}}
59371ea7
PH
193base62d: ${if or {\
194 {eq {${base62d:3D7}}{12345}}\
195 {eq {${base62d:9IX}}{12345}}\
0ce9abe6 196 }{OK}{NOT OK}}
59371ea7
PH
197base62 error: ${base62:12345x}
198base62d error:${base62d:0003D7.}
199
200hmac: ${hmac{md5}{somesecret}{mail.example.com 2002-10-17 11:30:59}}
201hmac: ${hmac{sha1}{somesecret}{mail.example.com 2002-10-17 11:30:59}}
202md5: ${md5:the quick brown fox jumps over the lazy dog}
203sha1: ${sha1:}
204sha1: ${sha1:abc}
205mask: ${mask:192.168.10.206/28}
206mask: ${mask:192.168.10.206/32}
207mask: ${mask:192.168.10.206/33}
208mask: ${mask:192.168.10.206/0}
209mask: ${mask:192.168.10.206}
210mask: ${mask:a.b.c.d}
fc4a7f70
JH
211ipv6denorm: ${ipv6denorm:::1}
212ipv6denorm: ${ipv6denorm:fe00::1}
213ipv6denorm: ${ipv6denorm:192.168.0.1}
214ipv6denorm: ${ipv6denorm:fe80::192.168.0.1}
215ipv6norm: ${ipv6norm:0:0:0::1}
216ipv6norm: ${ipv6norm:2a00::0}
217ipv6norm: ${ipv6norm:2a00::1}
218ipv6norm: ${ipv6norm:2a00:eadf:0000:0000:0000:0000:0001:0000}
219ipv6norm: ${ipv6norm:2a00:eadf:0000:0001:0000:0000:0000:0000}
220ipv6norm: ${ipv6norm:2a00:0:0:0::}
221ipv6norm: ${ipv6norm:2a00:2:3:4:5:6:7:8}
59371ea7
PH
222nhash: ${nhash_24:monty} ${nhash_8_63:monty python}
223lc/uc: ${lc:The Quick} ${uc: Brown Fox}
224length: ${length_10:The quick brown fox} ${l_10:abc}
225lclpt: ${local_part:local-part@dom.ain}
226lclpt: ${local_part:Exim Person <local-part@dom.ain> (that's me)}
227quote: ${quote:aZ09_.-Q} ${quote:ab*cd} ${quote:ab\cd"ef}
228quote: ${quote:nl(\n)}
229quote: ${quote:cr(\r)}
230quote: ${quote:tab(\t)}
231quote: ${quote:xff(\xff)}
232quote: Empty>${quote:}<
233quote_local_part: ${quote_local_part:abcd}
234quote_local_part: ${quote_local_part:O'Reilly}
235quote_local_part: ${quote_local_part:a space}
236quote_local_part: ${quote_local_part:.something}
237quote_local_part: ${quote_local_part:something.}
238quote_local_part: ${quote_local_part:joe.bloggs}
239quote_local_part: ${quote_local_part:a!b}
240quote_local_part: ${quote_local_part:x@y}
241quote_local_part: ${quote_local_part:ab*cd}
242quote_local_part: ${quote_local_part:x:y}
243quote_local_part: ${quote_local_part:ab\cd"ef}
244quote_local_part: ${quote_local_part:}
245rxquote:${rxquote:aZ09_,-Q} ${rxquote:ab*cd} ${rxquote:ab\cd"ef}
c10d53a2
JH
246hexquote: ${hexquote:\
247 \001\002\003\004\005\006\007 \010\011\012\013\014\015\016\017 \
248\020\021\022\023\024\025\026\027 \030\031\032\033\034\035\036\037 \
249\040\041\042\043\044\045\046\047 \050\051\052\053\054\055\056\057 \
250\060\061\062\063\064\065\066\067 \070\071\072\073\074\075\076\077 \
251\100\101\102\103\104\105\106\107 \110\111\112\113\114\115\116\117 \
252\120\121\122\123\124\125\126\127 \130\131\132\133\134\135\136\137 \
253\140\141\142\143\144\145\146\147 \150\151\152\153\154\155\156\157 \
254\160\161\162\163\164\165\166\167 \170\171\172\173\174\175\176\177}
59371ea7
PH
255substr: ${substr_3_2:rhubarb} ${s_-5_2:1234567} ${s_-5_2:12} ${s_-3_2:12}
256substr: ${s_3:rhubarb} ${s_-2:rhubarb}
257substr: ${s_1:}
258substr: ${substr_10:abc}
259str2b64:${str2b64:abcd}
260str2b64:${str2b64:The quick brown \n fox}
9aa35e9c
JH
261base64: ${base64:abcd}
262base64: ${base64:The quick brown \n fox}
263base64d:${base64d:YWJjZA==}
264base64d:${base64d:VGhlIHF1aWNrIGJyb3duIAogZm94}
59371ea7
PH
265strlen: ${strlen:}
266strlen: ${strlen:a}
267strlen: ${strlen:abcdefgh}
f90d018c
PH
268time_eval: ${time_eval:10s}
269time_eval: ${time_eval:2h}
270time_eval: ${time_eval:1d5m}
271time_eval: ${time_eval:1w2d3h4m5s}
272time_eval: ${time_eval:14}
273time_eval: ${time_eval:rhubarb}
59371ea7
PH
274time_interval: ${time_interval:0}
275time_interval: ${time_interval:44}
276time_interval: ${time_interval:999999}
277time_interval: ${time_interval:-1}
278time_interval: ${time_interval:rhubarb}
279
280# stat is a bit tricky, but some of the fields of the aux-var directory
281# should be the same on all systems
282
283stat: ${extract{mode}{${stat:DIR/aux-var}}}
284stat: ${extract{smode}{${stat:DIR/aux-var}}}
285stat: ${stat:/a/non/existent/file}
286
287# "Operators" that have expanded arguments
288
289hash: ${hash{3}{monty}} ${hash{5}{monty}} ${hash{4}{62}{monty python}}
290hash: ${hash{3}{abc}}X ${hash{3}{ab}}X ${hash{3}{a}}X ${hash{3}{}}X
291nhash: ${nhash{24}{monty}} ${nhash{8}{63}{monty python}}
292length: ${length{10}{The quick brown fox}} ${length{10}{abc}}
293substr: ${substr{3}{2}{rhubarb}} ${substr{-5}{2}{1234567}} ${substr{-5}{2}{12}} ${substr{-3}{2}{12}}
294substr: ${substr{${if eq{1}{1}{-8}}}{${if eq{1}{0}{25}{1}}}{abcde}}
295
296# Error forms
297
298${hash{one}}
299${hash{nonnumber}{abcd}}
300${hash{3}{2}{4}{abcd}}
301${substr{-3}{-2}{abcd}}
302
303# Skipped operators
304
305addrss: ${if eq {1}{2}{${address:invalid}}{NO}}
306domain: ${if eq {1}{2}{${domain:invalid}}{NO}}
307escape: ${if eq {1}{2}{${escape:invalid}}{NO}}
308expand: ${if eq {1}{2}{\$primary_hostname ${expand:\$invalid}}{NO}}
309hash: ${if eq {1}{2}{${hash_3:invalid}}{NO}}
310md5: ${if eq {1}{2}{${md5:invalid}}{NO}}
311mask: ${if eq {1}{2}{${mask:invalid}}{NO}}
312
4eb9d6ef
JH
313# Number suffixes in conditions
3141k: ${if >{1}{1k}{n}{y}}
3151K: ${if >{1}{1K}{n}{y}}
3161M: ${if >{1}{1M}{n}{y}}
3171G: ${if >{1}{1G}{n}{y}}
318
d45b1de8 319# Numeric overflow
aa7c82b2 320# >32b should work, >64b not
d45b1de8 321
725735cd
JH
3221 > 2047M ${if >{1}{2047M}{y}{n}}
3231 > 2048M ${if >{1}{2048M}{y}{n}}
3241 > 4096000000 ${if >{1}{4096000000}{y}{n}}
3251 > 4096M ${if >{1}{4096M}{y}{n}}
3261 > 4611686018427387904 ${if >{1}{4611686018427387904} {y}{n}}
3271 > 46116860184273879040 ${if >{1}{46116860184273879040}{y}{n}}
d45b1de8 328
59371ea7
PH
329# Conditions
330
3312=2: ${if ={2}{2}{y}{n}}
3322==2: ${if =={2}{2}{y}{n}}
3333=2: ${if ={3}{2}{y}{n}}
3342==3: ${if =={2}{3}{y}{n}}
335!2=2: ${if !={2}{2}{y}{n}}
336!2==2: ${if !=={2}{2}{y}{n}}
337!3=2: ${if !={3}{2}{y}{n}}
338!2==3: ${if !=={2}{3}{y}{n}}
3392>3: ${if >{2}{3}{y}{n}}
3403>3: ${if >{3}{3}{y}{n}}
3414>3: ${if >{4}{3}{y}{n}}
d45b1de8 3421>-1: ${if >{1}{-1}{y}{n}}
59371ea7
PH
3432>=3: ${if >={2}{3}{y}{n}}
3443>=3: ${if >={3}{3}{y}{n}}
3454>=3: ${if >={4}{3}{y}{n}}
3462<3: ${if <{2}{3}{y}{n}}
3473<3: ${if <{3}{3}{y}{n}}
3484<3: ${if <{4}{3}{y}{n}}
3492<=3: ${if <={2}{3}{y}{n}}
3503<=3: ${if <={3}{3}{y}{n}}
3514<=3: ${if <={4}{3}{y}{n}}
3525<=3: ${if <={ 5 } { 3 } {y}{n}}
d45b1de8 353-3<=1: ${if <={-3}{1}{y}{n}}
59371ea7
PH
354
3555>3k: ${if >{5 } {3k }{y}{n}}
3565>3m: ${if >{5 } {3m }{y}{n}}
3575>3z: ${if >{5 } {3z }{y}{n}}
3585>a: ${if >{ 5 } {a}{y}{n}}
0de7239e 3595>bad: ${if >{5 } {${lookup{trick}lsearch{DIR/aux-fixed/0002.lsearch}}} {y}{n}}
59371ea7 360
5dd1517f
PH
361>0: ${if > {}{0}{y}{n}}
362=: ${if = {}{}{y}{n}}
363-2<: ${if < {-2}{}{y}{n}}
36408>07: ${if > {08}{07}{y}{n}}
365011=11: ${if = {011}{11}{y}{n}}
366
59371ea7
PH
367def:y ${if def:tod_log{y}{n}}
368def:n ${if def:host{y}{n}}
369def:f ${if def:post{y}{n}}
370def:h_f ${if def:h_xxx {y}{n}}
371def:h_f ${if def:h_xxx:{y}{n}}
372def:d: ${if def:tod_log:{y}{n}}
373
374exists: ${if exists{/etc/passwd}{y}{n}}
375exists: ${if exists{/doesnt}{y}{n}}
376
377eq: ${if eq{abc}{abc}{y}{n}}
378eq: ${if eq{abc}{xyz}{y}{n}}
379!eq: ${if !eq{abc}{abc}{y}{n}}
380!eq: ${if !eq{abc}{xyz}{y}{n}}
381
382eqi: ${if eqi{abc}{abc}{y}{n}}
383eqi: ${if eqi{abc}{ABC}{y}{n}}
384eqi: ${if eqi{abc}{xyz}{y}{n}}
385!eqi: ${if !eqi{abc}{abc}{y}{n}}
386!eqi: ${if !eqi{abc}{aBc}{y}{n}}
387!eqi: ${if !eqi{abc}{xyz}{y}{n}}
388
389lt: ${if lt{ABC}{abc}{y}{n}}
390lti: ${if lti{ABC}{abc}{y}{n}}
391le: ${if le{ABC}{abc}{y}{n}}
392lei: ${if lei{ABC}{abc}{y}{n}}
393gt: ${if gt{ABC}{abc}{y}{n}}
394gti: ${if gti{ABC}{abc}{y}{n}}
395ge: ${if ge{ABC}{abc}{y}{n}}
396gei: ${if gei{ABC}{abc}{y}{n}}
397
398isip: ${if isip {1.2.3.4}{y}{n}} 1.2.3.4
399isip4: ${if isip4{1.2.3.4}{y}{n}} 1.2.3.4
400isip6: ${if isip6{1.2.3.4}{y}{n}} 1.2.3.4
401isip: ${if isip {1:2:3:4}{y}{n}} 1:2:3:4
402isip4: ${if isip4{1:2:3:4}{y}{n}} 1:2:3:4
403isip6: ${if isip6{1:2:3:4}{y}{n}} 1:2:3:4
404isip: ${if isip {::1}{y}{n}} ::1
405isip4: ${if isip4{::1}{y}{n}} ::1
406isip6: ${if isip6{::1}{y}{n}} ::1
407isip: ${if isip {fe80::a00:20ff:fe86:a061}{y}{n}} fe80::a00:20ff:fe86:a061
408isip4: ${if isip4{fe80::a00:20ff:fe86:a061}{y}{n}} fe80::a00:20ff:fe86:a061
409isip6: ${if isip6{fe80::a00:20ff:fe86:a061}{y}{n}} fe80::a00:20ff:fe86:a061
410isip: ${if isip {rhubarb}{y}{n}} rhubarb
411isip4: ${if isip4{rhubarb}{y}{n}} rhubarb
412isip6: ${if isip6{rhubarb}{y}{n}} rhubarb
413
414match: ${if match{abcd}{\N^([ab]+)(\w+)$\N}{$2$1}fail}
415match: ${if match{abcd}{^\N([ab]+)(\w+)$\N}{$2$1}fail}
416match: ${if match{abcd}{^([ab]+)(\\w+)\$}{$2$1}fail}
417match: ${if match{wxyz}{^([ab]+)(\\w+)\$}{$2$1}fail}
418match: ${if match{abcd}{^([ab]+)(\\w+)\$}{$2[${if match{xyz}{(.*)}{$1}fail}]$1}fail}
419
420match_domain: ${if match_domain{a.b.c}{x.y.z:a.b.c:p.q.r}{yes}{no}}
421match_domain: ${if match_domain{a.b.c}{x.y.z:p.q.r}{yes}{no}}
422match_domain: ${if match_domain{5.aa.bb}{+dlist}{yes}{no}}
423match_domain: ${if match_domain{xxxyz}{+dlist}{yes}{no}}
424match_domain: ${if match_domain{xyz}{+dlist}{yes}{no}}
425
f78eb7c6
PH
426${if match{x@zz.aa.bb}{^(.*)} \
427 { \
0ce9abe6 428 >$1< \
f78eb7c6
PH
429 ${if match_domain{${domain:$1}}{+dlist}{[$1]}} \
430 >$1< \
431 } \
0ce9abe6 432 { CAN'T HAPPEN}}
f78eb7c6
PH
433
434${if match{x@xxxabc}{^(.*)} \
435 { \
0ce9abe6 436 >$1< \
f78eb7c6
PH
437 ${if match_domain{${domain:$1}}{^\Nxxx(.*)\N}{[$1]}} \
438 >$1< \
439 } \
0ce9abe6 440 { CAN'T HAPPEN}}
f78eb7c6 441
59371ea7
PH
442match_address: ${if match_address{x@y.z}{p@q:*@y.z}{yes}{no}}
443match_address: ${if match_address{x@y.z}{p@q:x@*.z}{yes}{no}}
444
445match_local_part:${if match_local_part{jo}{jack:jill:jo:john}{yes}{no}}
446match_local_part:${if match_local_part{jo}{\N^\w\N}{yes}{no}}
447
448match_ip: 01 ${if match_ip{1.2.3.4}{4.5.6.7:1.2.3.4}}
449match_ip: 02 ${if match_ip{1.2.3.4}{4.5.6.7:1.2.3.6}}
450match_ip: 03 ${if match_ip{1.2.3.4}{4.5.6.7:1.2.3.6/24}}
451match_ip: 04 ${if match_ip{1.2.3.4}{4.5.6.7:1.2.3.6:*}}
452match_ip: 05 ${if match_ip{1.2.3.4}{4.5.6.7:1.2.3.6:name}}
453match_ip: 06 ${if match_ip{1.2.3.4}{:4.5.6.7}}
454match_ip: 07 ${if match_ip{}{:4.5.6.7}}
455match_ip: 08 ${if match_ip{V4NET.11.12.13}{+hlist}}
456match_ip: 09 ${if match_ip{V4NET.11.12.14}{+hlist}}
457match_ip: 10 ${if match_ip{192.168.3.4}{+hlist}}
458match_ip: 11 ${if match_ip{somename}{+hlist}}
459match_ip: 12 ${if match_ip{1.2.3.4}{lsearch;DIR/aux-fixed/0002.matchip}}
460match_ip: 13 ${if match_ip{1.2.3.4}{net-lsearch;DIR/aux-fixed/0002.matchip}}
461match_ip: 14 ${if match_ip{5.6.7.8}{net24-lsearch;DIR/aux-fixed/0002.matchip}}
6a3bceb1 462match_ip: 15 ${if match_ip{abcd::dcba}{net-iplsearch;DIR/aux-fixed/0002.matchip}}
59371ea7
PH
463
464queue_running: ${if queue_running{y}{n}}
465first_delivery: ${if first_delivery{y}{n}}
466
467queue_running after or: ${if or{{eq {0}{0}}{queue_running}}{y}{n}}
468first_delivery after or: ${if or{{eq {0}{0}}{first_delivery}}{y}{n}}
469
bef3ea7f
JH
470# acl expansion condition
471acl if: ${if acl {{a_ret}} {Y:$value}{N:$value}}
472acl if: ${if acl {{a_ret}{argY}} {Y:$value}{N:$value}}
473acl if: ${if acl {{a_deny}{argN}{arg2}} {Y:$value}{N:$value}}
474acl if: ${if acl {{a_defer}{argN}{arg2}} {Y:$value}{N:$value}}
475
59371ea7
PH
476# Default values for both if strings
477
478\${if eq{1}{1}} >${if eq{1}{1}}<
479\${if eq{1}{2}} >${if eq{1}{2}}<
480
481# Lookups: DIR is the testing directory. In this test we can only use the
482# lookups that are required in all cases.
483
484${lookup{postmaster}lsearch{DIR/aux-fixed/0002.aliases}{$value}fail}
485
486${lookup{x@y}lsearch*@{DIR/aux-fixed/0002.starat}{$value}fail}
487${lookup{x@z}lsearch*{DIR/aux-fixed/0002.starat}{$value}fail}
488${lookup{x@z}lsearch*@{DIR/aux-fixed/0002.starat}{$value}fail}
489${lookup{x@w}lsearch*@{DIR/aux-fixed/0002.starat}{$value}fail}
490
491${lookup{a.b.c.d}partial-lsearch{DIR/aux-fixed/0002.domains}{$value}fail}
492${lookup{x.y.z}partial-lsearch{DIR/aux-fixed/0002.domains}{$value}{failed x.y.z}}
493${lookup{p.q}partial-lsearch{DIR/aux-fixed/0002.domains}{$value}fail}
494${lookup{o.p.q}partial-lsearch{DIR/aux-fixed/0002.domains}{$value}fail}
495${lookup{m.n.o.p.q}partial-lsearch{DIR/aux-fixed/0002.domains}{$value}fail}
496${lookup{x.y.z}partial1-lsearch{DIR/aux-fixed/0002.domains}{$value}fail}
497${lookup{x.y.z}partial0-lsearch{DIR/aux-fixed/0002.domains}{$value}fail}
498
499q1: ${lookup{abc}lsearch{DIR/aux-fixed/0002.quoted}}
500q2: ${lookup{xyz}lsearch{DIR/aux-fixed/0002.quoted}}
501q3: ${lookup{pqr}lsearch{DIR/aux-fixed/0002.quoted}}
502q4: ${lookup{a:b}lsearch{DIR/aux-fixed/0002.quoted}}
503q5: ${lookup{"quoted"}lsearch{DIR/aux-fixed/0002.quoted}}
504q6: ${lookup{white space}lsearch{DIR/aux-fixed/0002.quoted}}
505q7: ${lookup{b\\s}lsearch{DIR/aux-fixed/0002.quoted}}
506
507abc: ${lookup{abc}wildlsearch{DIR/aux-var/0002.wild}}
508a.b.c: ${lookup{a.b.c}wildlsearch{DIR/aux-var/0002.wild}}
509ab.c: ${lookup{ab.c}wildlsearch{DIR/aux-var/0002.wild}}
510xyz: ${lookup{xyz}wildlsearch{DIR/aux-var/0002.wild}}
511Xyz: ${lookup{Xyz}wildlsearch{DIR/aux-var/0002.wild}}
512Zyz: ${lookup{Zyz}wildlsearch{DIR/aux-var/0002.wild}}
513a b: ${lookup{a b}wildlsearch{DIR/aux-var/0002.wild}}
514a b: ${lookup{a b}wildlsearch{DIR/aux-var/0002.wild}}
515a:b: ${lookup{a:b}wildlsearch{DIR/aux-var/0002.wild}}
516a.b: ${lookup{a.b}wildlsearch{DIR/aux-var/0002.wild}}
517a..b: ${lookup{a..b}wildlsearch{DIR/aux-var/0002.wild}}
518a9b: ${lookup{a9b}wildlsearch{DIR/aux-var/0002.wild}}
519a99b: ${lookup{a99b}wildlsearch{DIR/aux-var/0002.wild}}
520
521# Should give the same results as above because expansion does nothing
522
523abc: ${lookup{abc}nwildlsearch{DIR/aux-var/0002.wild}}
524a.b.c: ${lookup{a.b.c}nwildlsearch{DIR/aux-var/0002.wild}}
525ab.c: ${lookup{ab.c}nwildlsearch{DIR/aux-var/0002.wild}}
526xyz: ${lookup{xyz}nwildlsearch{DIR/aux-var/0002.wild}}
527Xyz: ${lookup{Xyz}nwildlsearch{DIR/aux-var/0002.wild}}
528Zyz: ${lookup{Zyz}nwildlsearch{DIR/aux-var/0002.wild}}
529a b: ${lookup{a b}nwildlsearch{DIR/aux-var/0002.wild}}
530a b: ${lookup{a b}nwildlsearch{DIR/aux-var/0002.wild}}
531a:b: ${lookup{a:b}nwildlsearch{DIR/aux-var/0002.wild}}
532
533# Should fail because of no expansion
534
535a.b: ${lookup{a.b}nwildlsearch{DIR/aux-var/0002.wild}{$value}{NO}}
536a..b: ${lookup{a..b}nwildlsearch{DIR/aux-var/0002.wild}{$value}{NO}}
537a9b: ${lookup{a9b}nwildlsearch{DIR/aux-var/0002.wild}{$value}{NO}}
538a99b: ${lookup{a99b}nwildlsearch{DIR/aux-var/0002.wild}{$value}{NO}}
539
540# But these should succeed
541
542a\\:b: ${lookup{a\\:b}nwildlsearch{DIR/aux-var/0002.wild}}
543a\\:Xb: ${lookup{a\\:Xb}nwildlsearch{DIR/aux-var/0002.wild}}
544
366fc9f0
PH
545# Some tests of case-(in)dependence
546
547MiXeD-CD: ${lookup{MiXeD-CD}nwildlsearch{DIR/aux-var/0002.wild}{$value}{NOT FOUND}}
548MixeD-CD: ${lookup{MixeD-CD}nwildlsearch{DIR/aux-var/0002.wild}{$value}{NOT FOUND}}
549MiXeD-Ncd: ${lookup{MiXeD-Ncd}nwildlsearch{DIR/aux-var/0002.wild}{$value}{NOT FOUND}}
550MixeD-Ncd: ${lookup{MixeD-Ncd}nwildlsearch{DIR/aux-var/0002.wild}{$value}{NOT FOUND}}
551
59371ea7
PH
552# IP address (CIDR) lookups
553
5541.2.3.4: ${lookup{1.2.3.4}iplsearch{DIR/aux-fixed/0002.iplsearch}}
5551.2.3.5: ${lookup{1.2.3.5}iplsearch{DIR/aux-fixed/0002.iplsearch}}
5561.2.3.5: ${lookup{1.2.3.5}iplsearch*{DIR/aux-fixed/0002.iplsearch}}
557abcd::cdab: ${lookup{abcd::cdab}iplsearch{DIR/aux-fixed/0002.iplsearch}}
558192.168.1.2: ${lookup{192.168.1.2}iplsearch{DIR/aux-fixed/0002.iplsearch}}
559192.168.5.6: ${lookup{192.168.5.6}iplsearch{DIR/aux-fixed/0002.iplsearch}}
560abcd:abcd:: ${lookup{abcd:abcd::}iplsearch{DIR/aux-fixed/0002.iplsearch}}
561abcd:abcd:1:: ${lookup{abcd:abcd:1::}iplsearch{DIR/aux-fixed/0002.iplsearch}}
562abcd:abcd::3 ${lookup{abcd:abcd::3}iplsearch{DIR/aux-fixed/0002.iplsearch}}
563rhubarb ${lookup{rhubarb}iplsearch{DIR/aux-fixed/0002.iplsearch}}
564
565
566# Nested Lookups - style 1
567
568${lookup{${lookup{key1}lsearch{DIR/aux-fixed/0002.rec}{$value}{key1f}}}lsearch{DIR/aux-fixed/0002.rec}{$value}fail}
569${lookup{${lookup{key3}lsearch{DIR/aux-fixed/0002.rec}{$value}{key1f}}}lsearch{DIR/aux-fixed/0002.rec}{$value}fail}
570
571# Nested Lookups - style 2
572
573${lookup{key1}lsearch{DIR/aux-fixed/0002.rec}{${lookup{$value}lsearch{DIR/aux-fixed/0002.rec}{$value}{failed for $value}}}{failed for key1}}
574${lookup{key3}lsearch{DIR/aux-fixed/0002.rec}{${lookup{$value}lsearch{DIR/aux-fixed/0002.rec}{$value}{failed for $value}}}{failed for key1}}
575
576# Other nesting tests
577
578${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}}}
579${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}}}
580${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}}}
581${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}}}
582
583# Lookup quotes for standardly expected lookups
584
585lsearch ${quote_lsearch: !@#\$%^&*()_-+=|\\~`1234567890\{[\}]qwertyuiop:;"'asdfghjkl<,>.?/zxcvbnm}
586xxx ${quote_xxx: !@#\$%^&*()_-+=|\\~`1234567890\{[\}]qwertyuiop:;"'asdfghjkl<,>.?/zxcvbnm}
587
588# Extract
589
590${extract{B}{A=1 B=2 C=3}}
591${extract{ B }{A=1 B=2 C=3}{$value}{NOT FOUND}}
592${extract{2}{:}{1:2:3}}
593${extract{ 2 }{:}{1:2:3}{$value}{NOT FOUND}}
594Empty:<${extract{D}{A=1 B=2 C=3}}>
595Empty:<${extract{4}{:}{1:2:3}}>
596${extract{C}{A=1 B=2 C=3}{<$value>}}
597${extract{3}{:}{1:2:3}{<$value>}}
598Empty:<${extract{Z}{A=1 B=2 C=3}{<$value>}}>
599Empty:<${extract{4}{:}{1:2:3}{<$value>}}>
600${extract{Z}{A=1 B=2 C=3}{<$value>}{no Z}}
601${extract{4}{:}{1:2:3}{<$value>}{no 4}}
602${extract{Z}{A=1 B=2 C=3}{<$value>}fail}
603${extract{4}{:}{1:2:3}{<$value>}fail}
604${extract{K4}{${sg{1=A 4=D 3=C}{(\\d+)=}{K\$1=}}}}
605${extract{0}{:}{a:b:c:d:e}{$value}{FAIL}}
606${extract{1}{:}{a:b:c:d:e}{$value}{FAIL}}
607${extract{-1}{:}{a:b:c:d:e}{$value}{FAIL}}
608${extract{-5}{:}{a:b:c:d:e}{$value}{FAIL}}
609${extract{-6}{:}{a:b:c:d:e}{$value}{FAIL}}
610${extract{-3}{:,}{a,,b::c}}
611${extract{2}{:,}{a,,b::c}}
612${extract{3}{:,}{a,,b::c}}
613${extract{a-b}{X = "one two" a-b "three four" 5=99}}
614${extract{}{X=3}}
615${extract{ }{X=3}}
616${extract{ 2 }{ }{a b c}}
617
93cc2d6e
JH
618${map{a,1:b,2:c,3}{${extract{1}{,}{$item}{$value}{}}}}
619${map{a,1:b,2:c,3}{${extract{1}{,}{$item}{$value}{failcase}{bogus_argument}}}}
620
59371ea7
PH
621# Translation
622
623abcdea aaa xyz ${tr{abcdea}{aaa}{xyz}}
624abcdea a z ${tr{abcdea}{a}{z}}
625abcdea a ${tr{abcdea}{a}{}}
626abcdea abc z ${tr{abcdea}{abc}{z}}
627
fdab5d49
JJ
628# Boolean
629"TrUe" ${if bool{TrUe}{true}{false}} EXPECT: true
630"FALSE" ${if bool{FALSE}{true}{false}} EXPECT: false
631" yes" ${if bool{ yes}{true}{false}} EXPECT: true
632" no" ${if bool{ no}{true}{false}} EXPECT: false
633"yes " ${if bool{yes }{true}{false}} EXPECT: true
51c7471d 634"-1" ${if bool{-1}{true}{false}} EXPECT: true
fdab5d49
JJ
635"0" ${if bool{0}{true}{false}} EXPECT: false
636"1" ${if bool{1}{true}{false}} EXPECT: true
637" 0 " ${if bool{ 0 }{true}{false}} EXPECT: false
638" 1 " ${if bool{ 1 }{true}{false}} EXPECT: true
639"1111111111111111111" ${if bool{1111111111111111111}{true}{false}} EXPECT: true
640"9" ${if bool{9}{true}{false}} EXPECT: true
641" " ${if bool{ }{true}{false}} EXPECT: false
642"text" ${if bool{text}{true}{false}} EXPECT: error
643" text" ${if bool{ text}{true}{false}} EXPECT: error
51c7471d 644"-text" ${if bool{-text}{true}{false}} EXPECT: error
fdab5d49
JJ
645"text " ${if bool{text }{true}{false}} EXPECT: error
646" text " ${if bool{ text }{true}{false}} EXPECT: error
647"00" ${if bool{00}{true}{false}} EXPECT: false
5ee6f336 648"!true" ${if !bool{true}{true}{false}} EXPECT: false
bdf15279 649"!false" ${if !bool{false}{true}{false}} EXPECT: true
fdab5d49
JJ
650
651"TrUe" ${if bool_lax{TrUe}{true}{false}} EXPECT: true
652"FALSE" ${if bool_lax{FALSE}{true}{false}} EXPECT: false
653" yes" ${if bool_lax{ yes}{true}{false}} EXPECT: true
654" no" ${if bool_lax{ no}{true}{false}} EXPECT: false
655"yes " ${if bool_lax{yes }{true}{false}} EXPECT: true
656"-1" ${if bool_lax{-1}{true}{false}} EXPECT: true
657"0" ${if bool_lax{0}{true}{false}} EXPECT: false
658"1" ${if bool_lax{1}{true}{false}} EXPECT: true
659" 0 " ${if bool_lax{ 0 }{true}{false}} EXPECT: false
660" 1 " ${if bool_lax{ 1 }{true}{false}} EXPECT: true
661"1111111111111111111" ${if bool_lax{1111111111111111111}{true}{false}} EXPECT: true
662"9" ${if bool_lax{9}{true}{false}} EXPECT: true
663" " ${if bool_lax{ }{true}{false}} EXPECT: false
664"text" ${if bool_lax{text}{true}{false}} EXPECT: true
665" text" ${if bool_lax{ text}{true}{false}} EXPECT: true
666"text " ${if bool_lax{text }{true}{false}} EXPECT: true
667" text " ${if bool_lax{ text }{true}{false}} EXPECT: true
668"00" ${if bool_lax{00}{true}{false}} EXPECT: true
bdf15279 669"!true" ${if !bool_lax{true}{true}{false}} EXPECT: false
5ee6f336 670"!false" ${if !bool_lax{false}{true}{false}} EXPECT: true
fdab5d49 671
59371ea7
PH
672# RFC 2047
673
674abcd ${rfc2047:abcd}
675<:abcd:> ${rfc2047:<:abcd:>}
676<:ab cd:> ${rfc2047:<:ab cd:>}
677Long: ${rfc2047: here we go: a string that is going to be encoded: it will go over the 75-char limit}
678Long: ${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}
679
9c57cbc0
PH
680# RFC 2047 decode
681
682${rfc2047d:abcd abcd}
683${rfc2047d:<:abcd:> =?iso-8859-8?Q?=3C=3Aabcd=3A=3E?=}
684${rfc2047d:<:ab cd:> =?iso-8859-8?Q?=3C=3Aab_cd=3A=3E?=}
685${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?=}
686${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?=}
59371ea7
PH
687
688# UTF-8
689
690abcd ${from_utf8:abcd}
691ad ${from_utf8:aÀÿd}
692toobig ${from_utf8:aĀd}
693
694# Substitution
695
696\${sg{abcdefabcdef}{abc}{xyz}} =${sg{abcdefabcdef}{abc}{xyz}}
697\${sg{ab:xy::z}{:}{::}} =${sg{ab:xy::z}{:}{::}}
698\${sg{abcdefabcdef}{(..)[^c]}{>\$1<}} =${sg{abcdefabcdef}{(..)[^c]}{>$1<}}
699\${sg{abcdefabcdef}{(..)[^c]}{>\\\$1<}} =${sg{abcdefabcdef}{(..)[^c]}{>\$1<}}
700\${sg{abcdefabcdef}{(..)[^c]}{>\\N\$1\\N<}}=${sg{abcdefabcdef}{(..)[^c]}{>\N$1\N<}}
701\${sg{abbab}{a*}{+}} =${sg{abbab}{a*}{+}}
702
703# File insertion
704
705${readfile}
706${readfile{DIR/aux-fixed/0002.readfile}}
707${readfile{DIR/aux-fixed/0002.readfile}{}}
708${readfile{DIR/aux-fixed/0002.readfile}{:}}
709${readfile{DIR/aux-fixed/0002.readfile}{ - }}
710${readfile{/non/exist/file}}
711${if exists{/non/exist/file}{${readfile{/non/exist/file}}}{non-exist}}
712>${readfile{DIR/aux-fixed/0002.readfile}{!}}\
713 <
714
715# Calling a command
716
717${run{DIR/aux-fixed/0002.runfile 0}}
718RC=$runrc
719${run{DIR/aux-fixed/0002.runfile 0}{1}{2}}
720RC=$runrc
721${run{DIR/aux-fixed/0002.runfile 0}{$value}{2}}
722RC=$runrc
723${run{DIR/aux-fixed/0002.runfile 1}{$value}{2}}
724RC=$runrc
725${run{DIR/aux-fixed/0002.runfile 1}{$value}{$value}}
726RC=$runrc
727${run{DIR/test-nonexist}{Y}{N}}
728RC=$runrc
729>>${run{DIR/bin/iefbr14}}<<
730RC=$runrc
731${if eq{1}{2}{${run{/non/exist}}}{1!=2}}
732RC=$runrc
733
734# PRVS
735
736${prvs{userx@test.ex}{secret}}
737${prvs{userx@test.ex}{secret}{1}}
738${prvs{userx@test.ex}{secret}{8}}
739
740# Syntax errors
741
742${prvs{userx@test.ex}{secret}{12}}
743${prvs{userx@test.ex}{secret}{rhubarb}}
744${prvs{userx@test.ex}{secret}{}}
745
746# Correct checks; can't put explicit addresses in the tests, because they
0ce9abe6 747# will change over time.
59371ea7
PH
748
749${prvscheck{${prvs{userx@test.ex}{secret}}}{secret}}
750result=$prvscheck_result
751
752${prvscheck{${prvs{userx@test.ex}{secret}{1}}}{secret}\
753{>$prvscheck_result< >$prvscheck_address< >$prvscheck_keynum<}}
754result=$prvscheck_result
755
756${prvscheck{${prvs{userx@test.ex}{secret}{8}}}{secret}{}}
757result=$prvscheck_result
758
759# Incorrect secret
760
761${prvscheck{${prvs{userx@test.ex}{secret}}}{socrot}}
762result=$prvscheck_result
763
764${prvscheck{${prvs{userx@test.ex}{secret}}}{socrot}{$prvscheck_keynum}}
765result=$prvscheck_result
766
767# Non-prvs address
768
769>>${prvscheck{userx@test.ex}{secret}}<<
770result=$prvscheck_result
771
772# Syntax errors
773
774${tod_log
775${tod_log+6
776${expand:abcd
777${expand:abcd${tod_log}
778${hmac{xxx}{a}{b}}
779${if and {xyz}{a}{b}}
780${if and {{xya}}{a}{b}}
781${if and {{${lookup{x}lsearch{/a/b}}}}{a}{b}}
782${if eq {$h_xyz}{1}{y}{n}}
0d85fa3f
PH
783${if eq {$h_xyz:}{1}{y}{n}
784${if def:h_xyz}{y}{n}}
59371ea7
PH
785${if or {eq {}{}{yes}{no}}
786${if or {{eq {}{}{yes}{no}}
787${if or {{eq {}{}}{yes}{no}}
788${substr_1_:12345}
789${substr__3:12345}
790
0ce9abe6
PH
791# Iterations: forany and forall
792
793${if forany{a:b:c}{eq{$item}{a}}{yes}{no}}
794${if forany{a:b:c}{eq{$item}{b}}{yes}{no}}
795${if forany{a:b:c}{eq{$item}{c}}{yes}{no}}
796${if forany {a:b:c} {eq {$item} {z}} {yes} {no}}
797${if !forany{a:b:c}{eq{$item}{z}}{yes}{no}}
798${if !forany{a:b:c}{eq{$item}{a}}{yes}{no}}
799${if forany{}{eq{$item}{a}}{yes}{no}}
800${if !forany{}{eq{$item}{a}}{yes}{no}}
801${if forany{<, $primary_hostname,foo,bar}{eq{$item}{$primary_hostname}}{yes}{no}}
802
803${if forany{}{yes}{no}}
804${if forany{a:b:c}{gt{$item}{a}{yes}{no}}
805
806${if forall{a:b:c}{match{$item}{^[a-c]\$}}{yes}{no}}
807${if forall{q:b:c}{match{$item}{^[a-c]\$}}{yes}{no}}
808${if forall{a:b:z}{match{$item}{^[a-c]\$}}{yes}{no}}
809${if forall{}{match{$item}{^[a-c]\$}}{yes}{no}}
810
811${if !forall{a:b:c}{match{$item}{^[a-c]\$}}{yes}{no}}
812${if !forall{q:b:c}{match{$item}{^[a-c]\$}}{yes}{no}}
813${if !forall{a:b:z}{match{$item}{^[a-c]\$}}{yes}{no}}
814${if !forall{}{match{$item}{^[a-c]\$}}{yes}{no}}
815
816# Expect yes
817${if forany{a:b:c}\
818 {\
819 eq\
820 {$item: ${if forall{x:y:z}{match{$item}{^[x-z]\$}}{true}{false}}}\
821 {$item: true}\
822 }\
823{outer=yes}{outer=no}} item='$item' (unset)
824
825# Expect no
826${if forany{a:b:c}\
827 {\
828 eq\
829 {$item: ${if !forall{x:y:z}{match{$item}{^[x-z]\$}}{true}{false}}}\
830 {$item: true}\
831 }\
832{outer=yes}{outer=no}}
833
834# Error inside nest - check message is helpful
835${if forany{a:b:c}\
836 {\
837 eq\
838 {$item: ${if forall{x:y:z}{match{$item}{^[x-z]\$}{true}{false}}}\
839 {$item: true}\
840 }\
841{outer=yes}{outer=no}}
842
843
59371ea7
PH
844# Miscellaneous (for bug fixes, etc)
845
846${if ={1}{1} {true}{${if ={1}{1} {true}{${if ={1}{1}{true}fail}}}}}
847
089fc87a
JH
848# Environment access
849
850${env {USER}}
851${env {NO_SUCH_VARIABLE} {oops, success} {correct}}
852
59371ea7
PH
853****
854# Test "escape" with print_topbitchars
855exim -be -DPTBC=print_topbitchars
856escape: ${escape:B7F2}
857****
858# Checkout expansion debugging
859exim -d-all+expand -be
860primary_hostname: $primary_hostname
861match: ${if match{abcd}{\N^([ab]+)(\w+)$\N}{$2$1}fail}
862match: ${if match{wxyz}{\N^([ab]+)(\w+)$\N}{$2$1}fail}
863${if eq {1}{1}{yes}{${lookup{xx}lsearch{/non/exist}}}}
864match_address: ${if match_address{a.b.c}{a.b.c}{yes}{no}}
865****
866# Sender host name and address etc, all unset
867exim -be
e1a3f32f 868-be Sender host name and address etc, all unset
59371ea7
PH
869-oMa sender_host_address = $sender_host_address
870 sender_host_port = $sender_host_port
871-oMaa sender_host_authenticated = $sender_host_authenticated
872-oMai authenticated_id = $authenticated_id
873-oMas authenticated_sender = $authenticated_sender
874-oMi interface_address = $interface_address
875 interface_port = $interface_port
876-oMr received_protocol = $received_protocol
877-oMs sender_host_name = $sender_host_name
878-oMt sender_ident = $sender_ident
879****
880# Sender host name and address etc, all set except host name.
881exim -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
e1a3f32f 882-be Sender host name and address etc, all set except host name.
59371ea7
PH
883-oMa sender_host_address = $sender_host_address
884 sender_host_port = $sender_host_port
885-oMaa sender_host_authenticated = $sender_host_authenticated
886-oMai authenticated_id = $authenticated_id
887-oMas authenticated_sender = $authenticated_sender
888-oMi interface_address = $interface_address
889 interface_port = $interface_port
890-oMr received_protocol = $received_protocol
891-oMt sender_ident = $sender_ident
892****
893# Sender host name explicitly set
894exim -be -oMa V4NET.0.0.1.1234 -oMs my.host.name
e1a3f32f 895-be Sender host name explicitly set
59371ea7
PH
896-oMa sender_host_address = $sender_host_address
897 sender_host_port = $sender_host_port
898-oMs sender_host_name = $sender_host_name
899****
900# Sender host name lookup fails (V4NET.11.12.13 is not reverse registered)
901exim -be -oMa V4NET.11.12.13
e1a3f32f 902be Sender host name lookup fails (V4NET.11.12.13 is not reverse registered)
59371ea7
PH
903-oMs sender_host_name = $sender_host_name
904 host_lookup_failed = $host_lookup_failed
905****
906# Sender host name and protocol set by Sendmail-compatible option
907exim -be -pspecial:host.name
e1a3f32f 908-be Sender host name and protocol set by Sendmail-compatible option
59371ea7
PH
909-p received_protocol = $received_protocol
910-p sender_host_name = $sender_host_name
911****
912# Sender host name and address etc, all set except host name,
913# which should therefore be looked up from the address, but not if
914# we are skipping. The debug output for this test will show when
915# the lookup occurs.
916exim -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
e1a3f32f 917-be Sender host name and address etc, all set except host name
59371ea7
PH
918-oMa sender_host_address = $sender_host_address
919 sender_host_port = $sender_host_port
920-oMaa sender_host_authenticated = $sender_host_authenticated
921-oMai authenticated_id = $authenticated_id
922-oMas authenticated_sender = $authenticated_sender
923-oMi interface_address = $interface_address
924 interface_port = $interface_port
925-oMr received_protocol = $received_protocol
926----> No lookup yet: ${if eq{black}{white}{$sender_host_name}{No}}
927-oMs sender_host_name = $sender_host_name
928-oMt sender_ident = $sender_ident
929****
930# Test no auto host name lookup for query-style lookups
931exim -d -bh V4NET.0.0.1
932****
933exim -d -bh V4NET.0.0.2
934****
935# Test $reply_address
936exim -bh V4NET.0.0.0
937mail from:<>
938rcpt to:<some@body>
939data
940.
941mail from:<>
942rcpt to:<some@body>
943data
944From: a@b
945.
946mail from:<>
947rcpt to:<some@body>
948data
949From: a@b
950Reply-to: c@d
951.
952mail from:<>
953rcpt to:<some@body>
954data
955Reply-to:
956.
957mail from:<>
958rcpt to:<some@body>
959data
960Reply-to:
961From: x@y
962.
963quit
964****
965# Check RFC 2047 decoding with (default) length check
966exim -bh V4NET.0.0.0
967mail from:<>
968rcpt to:<some@body>
969data
970Subject: =?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?=
971.
972quit
973****
974# Check RFC 2047 decoding with length check disabled
975exim -DLENCHECK=check_rfc2047_length=false -bh V4NET.0.0.0
976mail from:<>
977rcpt to:<some@body>
978data
979Subject: =?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?=
980.
981quit
982****
1688f43b
PH
983# Certain kind of error
984exim -d -be
985match_ip: 15 ${if match_ip{1.2.3.4}{1.2.3}}
986match_ip: 16 ${if match_ip{1.2.3.4}{1.2.3.4/abc}}
987****
6754ce8c
TL
988# Operation of inlist and negated inlist
989exim -be
990${if inlist{aa}{aa} {in list}{not in list}}
991${if !inlist{aa}{aa} {not in list}{in list}}
992****