Cast empty string to zero for numerical comparions and treat all numbers
[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
8 exim -be
9
10 # These expansions can test variables in the configuration, but as there
11 # is no message being processed, there is no message-related data. But
12 # that of course gets tested in plenty of other places.
13
14 # Some fixed variables
15
16 exim_path: $exim_path
17 primary_hostname: $primary_hostname
18 primary_hostname: ${primary_hostname}
19 qualify_domain: $qualify_domain
20 bounce_return_size_limit: ${bounce_return_size_limit}
21 spool_directory: $spool_directory
22 unknown: ${unknown}
23 h_subject: $h_subject:(should be empty)
24 h_subject:$h_subject (should be empty)
25 header in curlies: ${header_subject:} (should fail)
26
27 # \$message_headers should be empty
28 message_headers: >$message_headers<
29
30 # Continuation
31 x\
32 y
33 x\
34              y
35
36 # Overlong names and overbig numbers
37
38 +$aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
39 +${aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}
40 +$11111111111111111111111111111111111
41 +${11111111111111111111111111111111111}
42
43 # Operators
44
45 addrss: ${address:local-part@dom.ain}
46 addrss: ${address:Exim Person <local-part@dom.ain> (that's me)}
47 domain: ${domain:local-part@dom.ain}
48 domain: ${domain:Exim Person <local-part@dom.ain> (that's me)}
49 escape: ${escape:B7·F2ò}
50 eval:   ${eval:1+1}
51 eval:   ${eval:1+2*3}
52 eval:   ${eval:(1+2)*3}
53 eval:   ${eval:3/2*4}
54 eval:   ${eval:3*4/2}
55 eval:   ${eval:42}
56 eval:   ${eval:}
57 eval:   ${eval:-2}
58 eval:   ${eval:-2 - -3}
59 eval:   ${eval:-2 - (-3)}
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*(1+1))/2 + 40K}
66 eval:   ${eval:077}
67 eval:   ${eval:08}
68 eval10: ${eval10:077}
69 eval10: ${eval10:08}
70 eval10: ${eval10:0x1234}
71 eval:   ${eval:2+42%5}
72 eval:   ${eval:0xc&5}          
73 eval:   ${eval:0xc & 5 }          
74 eval:   ${eval:0x0c|5}          
75 eval:   ${eval:0xc^5}          
76 eval:   ${eval:0xc>>1}         
77 eval:   ${eval:0xc >> 2}         
78 eval:   ${eval:0xc >> 4 }         
79 eval:   ${eval:0xc<<1}         
80 eval:   ${eval:~255&0x1234}    
81 eval:   ${eval:~ 255&0x1234}    
82 eval:   ${eval: -(~255&0x1234)} 
83
84 expand: \$primary_hostname ${expand:\$primary_hostname}
85 hash:   ${hash_3:monty} ${hash_5:monty} ${hash_4_62:monty python}
86 hash:   ${hash_3:abc}X ${hash_3:ab}X ${hash_3:a}X ${hash_3:}X
87 hex2b64:${hex2b64:12345678}
88 hex2b64:${hex2b64:abcdef}
89 hex2b64:${hex2b64:ABCDEF}
90 hex2b64:${hex2b64:1a2b3c4d5e6f}
91 hex2b64:${hex2b64:1a2b3c4d5e6}
92 hex2b64:${hex2b64:1a2b3c4d5e6g}
93 hex2b64:${hex2b64:${md5:the quick brown fox}}
94 hex2b64:${hex2b64:${sha1:the quick brown fox}}
95
96 The base62 operator is actually a base36 operator in the Darwin and Cygwin
97 environments. Write cunning tests that produce the same output in both cases,
98 while doing a reasonable check.
99
100 base62:  ${if or {\
101                  {eq {${base62:12345}}{0003D7}}\
102                  {eq {${base62:12345}}{0009IX}}\
103                  }{OK}{NOT OK}} 
104 base62d: ${if or {\
105                  {eq {${base62d:0003D7}}{12345}}\
106                  {eq {${base62d:0009IX}}{12345}}\
107                  }{OK}{NOT OK}} 
108 base62d: ${if or {\
109                  {eq {${base62d:3D7}}{12345}}\
110                  {eq {${base62d:9IX}}{12345}}\
111                  }{OK}{NOT OK}} 
112 base62 error: ${base62:12345x}
113 base62d error:${base62d:0003D7.}
114
115 hmac:   ${hmac{md5}{somesecret}{mail.example.com 2002-10-17 11:30:59}}
116 hmac:   ${hmac{sha1}{somesecret}{mail.example.com 2002-10-17 11:30:59}}
117 md5:    ${md5:the quick brown fox jumps over the lazy dog}
118 sha1:   ${sha1:}
119 sha1:   ${sha1:abc}
120 mask:   ${mask:192.168.10.206/28}
121 mask:   ${mask:192.168.10.206/32}
122 mask:   ${mask:192.168.10.206/33}
123 mask:   ${mask:192.168.10.206/0}
124 mask:   ${mask:192.168.10.206}
125 mask:   ${mask:a.b.c.d}
126 nhash:  ${nhash_24:monty} ${nhash_8_63:monty python}
127 lc/uc:  ${lc:The Quick} ${uc: Brown Fox}
128 length: ${length_10:The quick brown fox} ${l_10:abc}
129 lclpt:  ${local_part:local-part@dom.ain}
130 lclpt:  ${local_part:Exim Person <local-part@dom.ain> (that's me)}
131 quote:  ${quote:aZ09_.-Q} ${quote:ab*cd} ${quote:ab\cd"ef}
132 quote:  ${quote:nl(\n)}
133 quote:  ${quote:cr(\r)}
134 quote:  ${quote:tab(\t)}
135 quote:  ${quote:xff(\xff)}
136 quote:  Empty>${quote:}<
137 quote_local_part: ${quote_local_part:abcd}
138 quote_local_part: ${quote_local_part:O'Reilly}
139 quote_local_part: ${quote_local_part:a space}
140 quote_local_part: ${quote_local_part:.something}
141 quote_local_part: ${quote_local_part:something.}
142 quote_local_part: ${quote_local_part:joe.bloggs}
143 quote_local_part: ${quote_local_part:a!b}
144 quote_local_part: ${quote_local_part:x@y}
145 quote_local_part: ${quote_local_part:ab*cd}
146 quote_local_part: ${quote_local_part:x:y}
147 quote_local_part: ${quote_local_part:ab\cd"ef}
148 quote_local_part: ${quote_local_part:}
149 rxquote:${rxquote:aZ09_,-Q} ${rxquote:ab*cd} ${rxquote:ab\cd"ef}
150 substr: ${substr_3_2:rhubarb} ${s_-5_2:1234567} ${s_-5_2:12} ${s_-3_2:12}
151 substr: ${s_3:rhubarb} ${s_-2:rhubarb}
152 substr: ${s_1:}
153 substr: ${substr_10:abc}
154 str2b64:${str2b64:abcd}
155 str2b64:${str2b64:The quick brown \n fox}
156 strlen: ${strlen:}
157 strlen: ${strlen:a}
158 strlen: ${strlen:abcdefgh}
159 time_eval:     ${time_eval:10s}
160 time_eval:     ${time_eval:2h}
161 time_eval:     ${time_eval:1d5m}
162 time_eval:     ${time_eval:1w2d3h4m5s}
163 time_eval:     ${time_eval:14}
164 time_eval:     ${time_eval:rhubarb}
165 time_interval: ${time_interval:0}
166 time_interval: ${time_interval:44}
167 time_interval: ${time_interval:999999}
168 time_interval: ${time_interval:-1}
169 time_interval: ${time_interval:rhubarb}
170
171 # stat is a bit tricky, but some of the fields of the aux-var directory
172 # should be the same on all systems
173
174 stat:   ${extract{mode}{${stat:DIR/aux-var}}}
175 stat:   ${extract{smode}{${stat:DIR/aux-var}}}
176 stat:   ${stat:/a/non/existent/file}
177
178 # "Operators" that have expanded arguments
179
180 hash:   ${hash{3}{monty}} ${hash{5}{monty}} ${hash{4}{62}{monty python}}
181 hash:   ${hash{3}{abc}}X ${hash{3}{ab}}X ${hash{3}{a}}X ${hash{3}{}}X
182 nhash:  ${nhash{24}{monty}} ${nhash{8}{63}{monty python}}
183 length: ${length{10}{The quick brown fox}} ${length{10}{abc}}
184 substr: ${substr{3}{2}{rhubarb}} ${substr{-5}{2}{1234567}} ${substr{-5}{2}{12}} ${substr{-3}{2}{12}}
185 substr: ${substr{${if eq{1}{1}{-8}}}{${if eq{1}{0}{25}{1}}}{abcde}}
186
187 # Error forms
188
189 ${hash{one}}
190 ${hash{nonnumber}{abcd}}
191 ${hash{3}{2}{4}{abcd}}
192 ${substr{-3}{-2}{abcd}}
193
194 # Skipped operators
195
196 addrss: ${if eq {1}{2}{${address:invalid}}{NO}}
197 domain: ${if eq {1}{2}{${domain:invalid}}{NO}}
198 escape: ${if eq {1}{2}{${escape:invalid}}{NO}}
199 expand: ${if eq {1}{2}{\$primary_hostname ${expand:\$invalid}}{NO}}
200 hash:   ${if eq {1}{2}{${hash_3:invalid}}{NO}}
201 md5:    ${if eq {1}{2}{${md5:invalid}}{NO}}
202 mask:   ${if eq {1}{2}{${mask:invalid}}{NO}}
203
204 # Numeric overflow
205
206 4096M      ${if >{1}{4096M}{y}{n}}
207 4096000000 ${if >{1}{4096000000}{y}{n}}
208
209 # Conditions
210
211 2=2:    ${if ={2}{2}{y}{n}}
212 2==2:   ${if =={2}{2}{y}{n}}
213 3=2:    ${if ={3}{2}{y}{n}}
214 2==3:   ${if =={2}{3}{y}{n}}
215 !2=2:   ${if !={2}{2}{y}{n}}
216 !2==2:  ${if !=={2}{2}{y}{n}}
217 !3=2:   ${if !={3}{2}{y}{n}}
218 !2==3:  ${if !=={2}{3}{y}{n}}
219 2>3:    ${if >{2}{3}{y}{n}}
220 3>3:    ${if >{3}{3}{y}{n}}
221 4>3:    ${if >{4}{3}{y}{n}}
222 1>-1:   ${if >{1}{-1}{y}{n}}
223 2>=3:   ${if >={2}{3}{y}{n}}
224 3>=3:   ${if >={3}{3}{y}{n}}
225 4>=3:   ${if >={4}{3}{y}{n}}
226 2<3:    ${if <{2}{3}{y}{n}}
227 3<3:    ${if <{3}{3}{y}{n}}
228 4<3:    ${if <{4}{3}{y}{n}}
229 2<=3:   ${if <={2}{3}{y}{n}}
230 3<=3:   ${if <={3}{3}{y}{n}}
231 4<=3:   ${if <={4}{3}{y}{n}}
232 5<=3:   ${if <={ 5 } { 3 } {y}{n}}
233 -3<=1:  ${if <={-3}{1}{y}{n}}
234
235 5>3k:   ${if >{5 } {3k }{y}{n}}
236 5>3m:   ${if >{5 } {3m }{y}{n}}
237 5>3z:   ${if >{5 } {3z }{y}{n}}
238 5>a:    ${if >{ 5 } {a}{y}{n}}
239
240 >0:     ${if > {}{0}{y}{n}}
241 =:      ${if = {}{}{y}{n}}
242 -2<:    ${if < {-2}{}{y}{n}}
243 08>07:  ${if > {08}{07}{y}{n}}
244 011=11: ${if = {011}{11}{y}{n}}
245
246 def:y   ${if def:tod_log{y}{n}}
247 def:n   ${if def:host{y}{n}}
248 def:f   ${if def:post{y}{n}}
249 def:h_f ${if def:h_xxx {y}{n}}
250 def:h_f ${if def:h_xxx:{y}{n}}
251 def:d:  ${if def:tod_log:{y}{n}}
252
253 exists: ${if exists{/etc/passwd}{y}{n}}
254 exists: ${if exists{/doesnt}{y}{n}}
255
256 eq:     ${if eq{abc}{abc}{y}{n}}
257 eq:     ${if eq{abc}{xyz}{y}{n}}
258 !eq:    ${if !eq{abc}{abc}{y}{n}}
259 !eq:    ${if !eq{abc}{xyz}{y}{n}}
260
261 eqi:    ${if eqi{abc}{abc}{y}{n}}
262 eqi:    ${if eqi{abc}{ABC}{y}{n}}
263 eqi:    ${if eqi{abc}{xyz}{y}{n}}
264 !eqi:   ${if !eqi{abc}{abc}{y}{n}}
265 !eqi:   ${if !eqi{abc}{aBc}{y}{n}}
266 !eqi:   ${if !eqi{abc}{xyz}{y}{n}}
267
268 lt:     ${if lt{ABC}{abc}{y}{n}}
269 lti:    ${if lti{ABC}{abc}{y}{n}}
270 le:     ${if le{ABC}{abc}{y}{n}}
271 lei:    ${if lei{ABC}{abc}{y}{n}}
272 gt:     ${if gt{ABC}{abc}{y}{n}}
273 gti:    ${if gti{ABC}{abc}{y}{n}}
274 ge:     ${if ge{ABC}{abc}{y}{n}}
275 gei:    ${if gei{ABC}{abc}{y}{n}}
276
277 isip:   ${if isip {1.2.3.4}{y}{n}}  1.2.3.4
278 isip4:  ${if isip4{1.2.3.4}{y}{n}}  1.2.3.4
279 isip6:  ${if isip6{1.2.3.4}{y}{n}}  1.2.3.4
280 isip:   ${if isip {1:2:3:4}{y}{n}}  1:2:3:4
281 isip4:  ${if isip4{1:2:3:4}{y}{n}}  1:2:3:4
282 isip6:  ${if isip6{1:2:3:4}{y}{n}}  1:2:3:4
283 isip:   ${if isip {::1}{y}{n}}      ::1
284 isip4:  ${if isip4{::1}{y}{n}}      ::1
285 isip6:  ${if isip6{::1}{y}{n}}      ::1
286 isip:   ${if isip {fe80::a00:20ff:fe86:a061}{y}{n}}  fe80::a00:20ff:fe86:a061
287 isip4:  ${if isip4{fe80::a00:20ff:fe86:a061}{y}{n}}  fe80::a00:20ff:fe86:a061
288 isip6:  ${if isip6{fe80::a00:20ff:fe86:a061}{y}{n}}  fe80::a00:20ff:fe86:a061
289 isip:   ${if isip {rhubarb}{y}{n}}  rhubarb
290 isip4:  ${if isip4{rhubarb}{y}{n}}  rhubarb
291 isip6:  ${if isip6{rhubarb}{y}{n}}  rhubarb
292
293 match:  ${if match{abcd}{\N^([ab]+)(\w+)$\N}{$2$1}fail}
294 match:  ${if match{abcd}{^\N([ab]+)(\w+)$\N}{$2$1}fail}
295 match:  ${if match{abcd}{^([ab]+)(\\w+)\$}{$2$1}fail}
296 match:  ${if match{wxyz}{^([ab]+)(\\w+)\$}{$2$1}fail}
297 match:  ${if match{abcd}{^([ab]+)(\\w+)\$}{$2[${if match{xyz}{(.*)}{$1}fail}]$1}fail}
298
299 match_domain:    ${if match_domain{a.b.c}{x.y.z:a.b.c:p.q.r}{yes}{no}}
300 match_domain:    ${if match_domain{a.b.c}{x.y.z:p.q.r}{yes}{no}}
301 match_domain:    ${if match_domain{5.aa.bb}{+dlist}{yes}{no}}
302 match_domain:    ${if match_domain{xxxyz}{+dlist}{yes}{no}}
303 match_domain:    ${if match_domain{xyz}{+dlist}{yes}{no}}
304
305 ${if match{x@zz.aa.bb}{^(.*)} \
306   { \
307   >$1< \ 
308   ${if match_domain{${domain:$1}}{+dlist}{[$1]}} \
309   >$1< \
310   } \
311   { CAN'T HAPPEN}} 
312
313 ${if match{x@xxxabc}{^(.*)} \
314   { \
315   >$1< \ 
316   ${if match_domain{${domain:$1}}{^\Nxxx(.*)\N}{[$1]}} \
317   >$1< \
318   } \
319   { CAN'T HAPPEN}} 
320
321 match_address:   ${if match_address{x@y.z}{p@q:*@y.z}{yes}{no}}
322 match_address:   ${if match_address{x@y.z}{p@q:x@*.z}{yes}{no}}
323
324 match_local_part:${if match_local_part{jo}{jack:jill:jo:john}{yes}{no}}
325 match_local_part:${if match_local_part{jo}{\N^\w\N}{yes}{no}}
326
327 match_ip:        01 ${if match_ip{1.2.3.4}{4.5.6.7:1.2.3.4}}
328 match_ip:        02 ${if match_ip{1.2.3.4}{4.5.6.7:1.2.3.6}}
329 match_ip:        03 ${if match_ip{1.2.3.4}{4.5.6.7:1.2.3.6/24}}
330 match_ip:        04 ${if match_ip{1.2.3.4}{4.5.6.7:1.2.3.6:*}}
331 match_ip:        05 ${if match_ip{1.2.3.4}{4.5.6.7:1.2.3.6:name}}
332 match_ip:        06 ${if match_ip{1.2.3.4}{:4.5.6.7}}
333 match_ip:        07 ${if match_ip{}{:4.5.6.7}}
334 match_ip:        08 ${if match_ip{V4NET.11.12.13}{+hlist}}
335 match_ip:        09 ${if match_ip{V4NET.11.12.14}{+hlist}}
336 match_ip:        10 ${if match_ip{192.168.3.4}{+hlist}}
337 match_ip:        11 ${if match_ip{somename}{+hlist}}
338 match_ip:        12 ${if match_ip{1.2.3.4}{lsearch;DIR/aux-fixed/0002.matchip}}
339 match_ip:        13 ${if match_ip{1.2.3.4}{net-lsearch;DIR/aux-fixed/0002.matchip}}
340 match_ip:        14 ${if match_ip{5.6.7.8}{net24-lsearch;DIR/aux-fixed/0002.matchip}}
341
342 queue_running:  ${if queue_running{y}{n}}
343 first_delivery: ${if first_delivery{y}{n}}
344
345 queue_running after or: ${if or{{eq {0}{0}}{queue_running}}{y}{n}}
346 first_delivery after or: ${if or{{eq {0}{0}}{first_delivery}}{y}{n}}
347
348 # Default values for both if strings
349
350 \${if eq{1}{1}}  >${if eq{1}{1}}<
351 \${if eq{1}{2}}  >${if eq{1}{2}}<
352
353 # Lookups: DIR is the testing directory. In this test we can only use the
354 # lookups that are required in all cases.
355
356 ${lookup{postmaster}lsearch{DIR/aux-fixed/0002.aliases}{$value}fail}
357
358 ${lookup{x@y}lsearch*@{DIR/aux-fixed/0002.starat}{$value}fail}
359 ${lookup{x@z}lsearch*{DIR/aux-fixed/0002.starat}{$value}fail}
360 ${lookup{x@z}lsearch*@{DIR/aux-fixed/0002.starat}{$value}fail}
361 ${lookup{x@w}lsearch*@{DIR/aux-fixed/0002.starat}{$value}fail}
362
363 ${lookup{a.b.c.d}partial-lsearch{DIR/aux-fixed/0002.domains}{$value}fail}
364 ${lookup{x.y.z}partial-lsearch{DIR/aux-fixed/0002.domains}{$value}{failed x.y.z}}
365 ${lookup{p.q}partial-lsearch{DIR/aux-fixed/0002.domains}{$value}fail}
366 ${lookup{o.p.q}partial-lsearch{DIR/aux-fixed/0002.domains}{$value}fail}
367 ${lookup{m.n.o.p.q}partial-lsearch{DIR/aux-fixed/0002.domains}{$value}fail}
368 ${lookup{x.y.z}partial1-lsearch{DIR/aux-fixed/0002.domains}{$value}fail}
369 ${lookup{x.y.z}partial0-lsearch{DIR/aux-fixed/0002.domains}{$value}fail}
370
371 q1:  ${lookup{abc}lsearch{DIR/aux-fixed/0002.quoted}}
372 q2:  ${lookup{xyz}lsearch{DIR/aux-fixed/0002.quoted}}
373 q3:  ${lookup{pqr}lsearch{DIR/aux-fixed/0002.quoted}}
374 q4:  ${lookup{a:b}lsearch{DIR/aux-fixed/0002.quoted}}
375 q5:  ${lookup{"quoted"}lsearch{DIR/aux-fixed/0002.quoted}}
376 q6:  ${lookup{white space}lsearch{DIR/aux-fixed/0002.quoted}}
377 q7:  ${lookup{b\\s}lsearch{DIR/aux-fixed/0002.quoted}}
378
379 abc:   ${lookup{abc}wildlsearch{DIR/aux-var/0002.wild}}
380 a.b.c: ${lookup{a.b.c}wildlsearch{DIR/aux-var/0002.wild}}
381 ab.c:  ${lookup{ab.c}wildlsearch{DIR/aux-var/0002.wild}}
382 xyz:   ${lookup{xyz}wildlsearch{DIR/aux-var/0002.wild}}
383 Xyz:   ${lookup{Xyz}wildlsearch{DIR/aux-var/0002.wild}}
384 Zyz:   ${lookup{Zyz}wildlsearch{DIR/aux-var/0002.wild}}
385 a b:   ${lookup{a b}wildlsearch{DIR/aux-var/0002.wild}}
386 a  b:  ${lookup{a  b}wildlsearch{DIR/aux-var/0002.wild}}
387 a:b:   ${lookup{a:b}wildlsearch{DIR/aux-var/0002.wild}}
388 a.b:   ${lookup{a.b}wildlsearch{DIR/aux-var/0002.wild}}
389 a..b:  ${lookup{a..b}wildlsearch{DIR/aux-var/0002.wild}}
390 a9b:   ${lookup{a9b}wildlsearch{DIR/aux-var/0002.wild}}
391 a99b:  ${lookup{a99b}wildlsearch{DIR/aux-var/0002.wild}}
392
393 # Should give the same results as above because expansion does nothing
394
395 abc:   ${lookup{abc}nwildlsearch{DIR/aux-var/0002.wild}}
396 a.b.c: ${lookup{a.b.c}nwildlsearch{DIR/aux-var/0002.wild}}
397 ab.c:  ${lookup{ab.c}nwildlsearch{DIR/aux-var/0002.wild}}
398 xyz:   ${lookup{xyz}nwildlsearch{DIR/aux-var/0002.wild}}
399 Xyz:   ${lookup{Xyz}nwildlsearch{DIR/aux-var/0002.wild}}
400 Zyz:   ${lookup{Zyz}nwildlsearch{DIR/aux-var/0002.wild}}
401 a b:   ${lookup{a b}nwildlsearch{DIR/aux-var/0002.wild}}
402 a  b:  ${lookup{a  b}nwildlsearch{DIR/aux-var/0002.wild}}
403 a:b:   ${lookup{a:b}nwildlsearch{DIR/aux-var/0002.wild}}
404
405 # Should fail because of no expansion
406
407 a.b:   ${lookup{a.b}nwildlsearch{DIR/aux-var/0002.wild}{$value}{NO}}
408 a..b:  ${lookup{a..b}nwildlsearch{DIR/aux-var/0002.wild}{$value}{NO}}
409 a9b:   ${lookup{a9b}nwildlsearch{DIR/aux-var/0002.wild}{$value}{NO}}
410 a99b:  ${lookup{a99b}nwildlsearch{DIR/aux-var/0002.wild}{$value}{NO}}
411
412 # But these should succeed
413
414 a\\:b:  ${lookup{a\\:b}nwildlsearch{DIR/aux-var/0002.wild}}
415 a\\:Xb: ${lookup{a\\:Xb}nwildlsearch{DIR/aux-var/0002.wild}}
416
417 # Some tests of case-(in)dependence
418
419 MiXeD-CD:  ${lookup{MiXeD-CD}nwildlsearch{DIR/aux-var/0002.wild}{$value}{NOT FOUND}}
420 MixeD-CD:  ${lookup{MixeD-CD}nwildlsearch{DIR/aux-var/0002.wild}{$value}{NOT FOUND}}
421 MiXeD-Ncd: ${lookup{MiXeD-Ncd}nwildlsearch{DIR/aux-var/0002.wild}{$value}{NOT FOUND}}
422 MixeD-Ncd: ${lookup{MixeD-Ncd}nwildlsearch{DIR/aux-var/0002.wild}{$value}{NOT FOUND}}
423
424 # IP address (CIDR) lookups
425
426 1.2.3.4:      ${lookup{1.2.3.4}iplsearch{DIR/aux-fixed/0002.iplsearch}}
427 1.2.3.5:      ${lookup{1.2.3.5}iplsearch{DIR/aux-fixed/0002.iplsearch}}
428 1.2.3.5:      ${lookup{1.2.3.5}iplsearch*{DIR/aux-fixed/0002.iplsearch}}
429 abcd::cdab:   ${lookup{abcd::cdab}iplsearch{DIR/aux-fixed/0002.iplsearch}}
430 192.168.1.2:  ${lookup{192.168.1.2}iplsearch{DIR/aux-fixed/0002.iplsearch}}
431 192.168.5.6:  ${lookup{192.168.5.6}iplsearch{DIR/aux-fixed/0002.iplsearch}}
432 abcd:abcd::   ${lookup{abcd:abcd::}iplsearch{DIR/aux-fixed/0002.iplsearch}}
433 abcd:abcd:1:: ${lookup{abcd:abcd:1::}iplsearch{DIR/aux-fixed/0002.iplsearch}}
434 abcd:abcd::3  ${lookup{abcd:abcd::3}iplsearch{DIR/aux-fixed/0002.iplsearch}}
435 rhubarb       ${lookup{rhubarb}iplsearch{DIR/aux-fixed/0002.iplsearch}}
436
437
438 # Nested Lookups - style 1
439
440 ${lookup{${lookup{key1}lsearch{DIR/aux-fixed/0002.rec}{$value}{key1f}}}lsearch{DIR/aux-fixed/0002.rec}{$value}fail}
441 ${lookup{${lookup{key3}lsearch{DIR/aux-fixed/0002.rec}{$value}{key1f}}}lsearch{DIR/aux-fixed/0002.rec}{$value}fail}
442
443 # Nested Lookups - style 2
444
445 ${lookup{key1}lsearch{DIR/aux-fixed/0002.rec}{${lookup{$value}lsearch{DIR/aux-fixed/0002.rec}{$value}{failed for $value}}}{failed for key1}}
446 ${lookup{key3}lsearch{DIR/aux-fixed/0002.rec}{${lookup{$value}lsearch{DIR/aux-fixed/0002.rec}{$value}{failed for $value}}}{failed for key1}}
447
448 # Other nesting tests
449
450 ${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}}}
451 ${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}}}
452 ${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}}}
453 ${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}}}
454
455 # Lookup quotes for standardly expected lookups
456
457 lsearch ${quote_lsearch: !@#\$%^&*()_-+=|\\~`1234567890\{[\}]qwertyuiop:;"'asdfghjkl<,>.?/zxcvbnm}
458 xxx     ${quote_xxx: !@#\$%^&*()_-+=|\\~`1234567890\{[\}]qwertyuiop:;"'asdfghjkl<,>.?/zxcvbnm}
459
460 # Extract
461
462 ${extract{B}{A=1 B=2 C=3}}
463 ${extract{ B }{A=1 B=2 C=3}{$value}{NOT FOUND}}
464 ${extract{2}{:}{1:2:3}}
465 ${extract{ 2 }{:}{1:2:3}{$value}{NOT FOUND}}
466 Empty:<${extract{D}{A=1 B=2 C=3}}>
467 Empty:<${extract{4}{:}{1:2:3}}>
468 ${extract{C}{A=1 B=2 C=3}{<$value>}}
469 ${extract{3}{:}{1:2:3}{<$value>}}
470 Empty:<${extract{Z}{A=1 B=2 C=3}{<$value>}}>
471 Empty:<${extract{4}{:}{1:2:3}{<$value>}}>
472 ${extract{Z}{A=1 B=2 C=3}{<$value>}{no Z}}
473 ${extract{4}{:}{1:2:3}{<$value>}{no 4}}
474 ${extract{Z}{A=1 B=2 C=3}{<$value>}fail}
475 ${extract{4}{:}{1:2:3}{<$value>}fail}
476 ${extract{K4}{${sg{1=A 4=D 3=C}{(\\d+)=}{K\$1=}}}}
477 ${extract{0}{:}{a:b:c:d:e}{$value}{FAIL}}
478 ${extract{1}{:}{a:b:c:d:e}{$value}{FAIL}}
479 ${extract{-1}{:}{a:b:c:d:e}{$value}{FAIL}}
480 ${extract{-5}{:}{a:b:c:d:e}{$value}{FAIL}}
481 ${extract{-6}{:}{a:b:c:d:e}{$value}{FAIL}}
482 ${extract{-3}{:,}{a,,b::c}}
483 ${extract{2}{:,}{a,,b::c}}
484 ${extract{3}{:,}{a,,b::c}}
485 ${extract{a-b}{X = "one two" a-b "three four" 5=99}}
486 ${extract{}{X=3}}
487 ${extract{ }{X=3}}
488 ${extract{ 2 }{ }{a b c}}
489
490 # Translation
491
492 abcdea aaa xyz ${tr{abcdea}{aaa}{xyz}}
493 abcdea a   z   ${tr{abcdea}{a}{z}}
494 abcdea a       ${tr{abcdea}{a}{}}
495 abcdea abc z   ${tr{abcdea}{abc}{z}}
496
497 # RFC 2047
498
499 abcd      ${rfc2047:abcd}
500 <:abcd:>  ${rfc2047:<:abcd:>}
501 <:ab cd:> ${rfc2047:<:ab cd:>}
502 Long:     ${rfc2047: here we go: a string that is going to be encoded: it will go over the 75-char limit}
503 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}
504
505
506 # UTF-8
507
508 abcd      ${from_utf8:abcd}
509 aÀÿd      ${from_utf8:aÃ\80ÿd}
510 toobig    ${from_utf8:aĀd}
511
512 # Substitution
513
514 \${sg{abcdefabcdef}{abc}{xyz}}          =${sg{abcdefabcdef}{abc}{xyz}}
515 \${sg{ab:xy::z}{:}{::}}                 =${sg{ab:xy::z}{:}{::}}
516 \${sg{abcdefabcdef}{(..)[^c]}{>\$1<}}    =${sg{abcdefabcdef}{(..)[^c]}{>$1<}}
517 \${sg{abcdefabcdef}{(..)[^c]}{>\\\$1<}}   =${sg{abcdefabcdef}{(..)[^c]}{>\$1<}}
518 \${sg{abcdefabcdef}{(..)[^c]}{>\\N\$1\\N<}}=${sg{abcdefabcdef}{(..)[^c]}{>\N$1\N<}}
519 \${sg{abbab}{a*}{+}}                    =${sg{abbab}{a*}{+}}
520
521 # File insertion
522
523 ${readfile}
524 ${readfile{DIR/aux-fixed/0002.readfile}}
525 ${readfile{DIR/aux-fixed/0002.readfile}{}}
526 ${readfile{DIR/aux-fixed/0002.readfile}{:}}
527 ${readfile{DIR/aux-fixed/0002.readfile}{ - }}
528 ${readfile{/non/exist/file}}
529 ${if exists{/non/exist/file}{${readfile{/non/exist/file}}}{non-exist}}
530 >${readfile{DIR/aux-fixed/0002.readfile}{!}}\
531     <
532
533 # Calling a command
534
535 ${run{DIR/aux-fixed/0002.runfile 0}}
536 RC=$runrc
537 ${run{DIR/aux-fixed/0002.runfile 0}{1}{2}}
538 RC=$runrc
539 ${run{DIR/aux-fixed/0002.runfile 0}{$value}{2}}
540 RC=$runrc
541 ${run{DIR/aux-fixed/0002.runfile 1}{$value}{2}}
542 RC=$runrc
543 ${run{DIR/aux-fixed/0002.runfile 1}{$value}{$value}}
544 RC=$runrc
545 ${run{DIR/test-nonexist}{Y}{N}}
546 RC=$runrc
547 >>${run{DIR/bin/iefbr14}}<<
548 RC=$runrc
549 ${if eq{1}{2}{${run{/non/exist}}}{1!=2}}
550 RC=$runrc
551
552 # PRVS
553
554 ${prvs{userx@test.ex}{secret}}
555 ${prvs{userx@test.ex}{secret}{1}}
556 ${prvs{userx@test.ex}{secret}{8}}
557
558 # Syntax errors
559
560 ${prvs{userx@test.ex}{secret}{12}}
561 ${prvs{userx@test.ex}{secret}{rhubarb}}
562 ${prvs{userx@test.ex}{secret}{}}
563
564 # Correct checks; can't put explicit addresses in the tests, because they
565 # will change over time. 
566
567 ${prvscheck{${prvs{userx@test.ex}{secret}}}{secret}}
568 result=$prvscheck_result
569
570 ${prvscheck{${prvs{userx@test.ex}{secret}{1}}}{secret}\
571 {>$prvscheck_result< >$prvscheck_address< >$prvscheck_keynum<}}
572 result=$prvscheck_result
573
574 ${prvscheck{${prvs{userx@test.ex}{secret}{8}}}{secret}{}}
575 result=$prvscheck_result
576
577 # Incorrect secret
578
579 ${prvscheck{${prvs{userx@test.ex}{secret}}}{socrot}}
580 result=$prvscheck_result
581
582 ${prvscheck{${prvs{userx@test.ex}{secret}}}{socrot}{$prvscheck_keynum}}
583 result=$prvscheck_result
584
585 # Non-prvs address
586
587 >>${prvscheck{userx@test.ex}{secret}}<<
588 result=$prvscheck_result
589
590 # Syntax errors
591
592 ${tod_log
593 ${tod_log+6
594 ${expand:abcd
595 ${expand:abcd${tod_log}
596 ${hmac{xxx}{a}{b}}
597 ${if and {xyz}{a}{b}}
598 ${if and {{xya}}{a}{b}}
599 ${if and {{${lookup{x}lsearch{/a/b}}}}{a}{b}}
600 ${if eq {$h_xyz}{1}{y}{n}}
601 ${if eq {$h_xyz:}{1}{y}{n}
602 ${if def:h_xyz}{y}{n}}
603 ${if or {eq {}{}{yes}{no}}
604 ${if or {{eq {}{}{yes}{no}}
605 ${if or {{eq {}{}}{yes}{no}}
606 ${substr_1_:12345}
607 ${substr__3:12345}
608
609 # Miscellaneous (for bug fixes, etc)
610
611 ${if ={1}{1} {true}{${if ={1}{1} {true}{${if ={1}{1}{true}fail}}}}}
612
613 ****
614 # Test "escape" with print_topbitchars
615 exim -be -DPTBC=print_topbitchars
616 escape: ${escape:B7·F2ò}
617 ****
618 # Checkout expansion debugging
619 exim -d-all+expand -be
620 primary_hostname: $primary_hostname
621 match:  ${if match{abcd}{\N^([ab]+)(\w+)$\N}{$2$1}fail}
622 match:  ${if match{wxyz}{\N^([ab]+)(\w+)$\N}{$2$1}fail}
623 ${if eq {1}{1}{yes}{${lookup{xx}lsearch{/non/exist}}}}
624 match_address:   ${if match_address{a.b.c}{a.b.c}{yes}{no}}
625 ****
626 # Sender host name and address etc, all unset
627 exim -be
628 -oMa  sender_host_address = $sender_host_address
629       sender_host_port = $sender_host_port
630 -oMaa sender_host_authenticated = $sender_host_authenticated
631 -oMai authenticated_id = $authenticated_id
632 -oMas authenticated_sender = $authenticated_sender
633 -oMi  interface_address = $interface_address
634       interface_port = $interface_port
635 -oMr  received_protocol = $received_protocol
636 -oMs  sender_host_name = $sender_host_name
637 -oMt  sender_ident = $sender_ident
638 ****
639 # Sender host name and address etc, all set except host name.
640 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
641 -oMa  sender_host_address = $sender_host_address
642       sender_host_port = $sender_host_port
643 -oMaa sender_host_authenticated = $sender_host_authenticated
644 -oMai authenticated_id = $authenticated_id
645 -oMas authenticated_sender = $authenticated_sender
646 -oMi  interface_address = $interface_address
647       interface_port = $interface_port
648 -oMr  received_protocol = $received_protocol
649 -oMt  sender_ident = $sender_ident
650 ****
651 # Sender host name explicitly set
652 exim -be -oMa V4NET.0.0.1.1234 -oMs my.host.name
653 -oMa  sender_host_address = $sender_host_address
654       sender_host_port = $sender_host_port
655 -oMs  sender_host_name = $sender_host_name
656 ****
657 # Sender host name lookup fails (V4NET.11.12.13 is not reverse registered)
658 exim -be -oMa V4NET.11.12.13
659 -oMs  sender_host_name = $sender_host_name
660       host_lookup_failed = $host_lookup_failed
661 ****
662 # Sender host name and protocol set by Sendmail-compatible option
663 exim -be -pspecial:host.name
664 -p  received_protocol = $received_protocol
665 -p  sender_host_name = $sender_host_name
666 ****
667 # Sender host name and address etc, all set except host name,
668 # which should therefore be looked up from the address, but not if
669 # we are skipping. The debug output for this test will show when
670 # the lookup occurs.
671 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
672 -oMa  sender_host_address = $sender_host_address
673       sender_host_port = $sender_host_port
674 -oMaa sender_host_authenticated = $sender_host_authenticated
675 -oMai authenticated_id = $authenticated_id
676 -oMas authenticated_sender = $authenticated_sender
677 -oMi  interface_address = $interface_address
678       interface_port = $interface_port
679 -oMr  received_protocol = $received_protocol
680 ----> No lookup yet: ${if eq{black}{white}{$sender_host_name}{No}}
681 -oMs  sender_host_name = $sender_host_name
682 -oMt  sender_ident = $sender_ident
683 ****
684 # Test no auto host name lookup for query-style lookups
685 exim -d -bh V4NET.0.0.1
686 ****
687 exim -d -bh V4NET.0.0.2
688 ****
689 # Test $reply_address
690 exim -bh V4NET.0.0.0
691 mail from:<>
692 rcpt to:<some@body>
693 data
694 .
695 mail from:<>
696 rcpt to:<some@body>
697 data
698 From: a@b
699 .
700 mail from:<>
701 rcpt to:<some@body>
702 data
703 From: a@b
704 Reply-to: c@d
705 .
706 mail from:<>
707 rcpt to:<some@body>
708 data
709 Reply-to:
710 .
711 mail from:<>
712 rcpt to:<some@body>
713 data
714 Reply-to:
715 From: x@y
716 .
717 quit
718 ****
719 # Check RFC 2047 decoding with (default) length check
720 exim -bh V4NET.0.0.0
721 mail from:<>
722 rcpt to:<some@body>
723 data
724 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?=
725 .
726 quit
727 ****
728 # Check RFC 2047 decoding with length check disabled
729 exim -DLENCHECK=check_rfc2047_length=false -bh V4NET.0.0.0
730 mail from:<>
731 rcpt to:<some@body>
732 data
733 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?=
734 .
735 quit
736 ****
737 # Certain kind of error
738 exim -d -be
739 match_ip:        15 ${if match_ip{1.2.3.4}{1.2.3}}
740 match_ip:        16 ${if match_ip{1.2.3.4}{1.2.3.4/abc}}
741 ****