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