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