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