Commit dee48251 dee4825117c6de0e359a103f9b6f7e8267dcb163 by Sergey Poznyakoff

Adjust for the recent changes in symbol space functions

(sieve_test_header): New tag :mime. Directs header to test
headers in all parts of a multipart message, not only main
message headers.
1 parent b49e4d91
...@@ -87,7 +87,7 @@ sieve_test_address (sieve_machine_t mach, list_t args, list_t tags) ...@@ -87,7 +87,7 @@ sieve_test_address (sieve_machine_t mach, list_t args, list_t tags)
87 { 87 {
88 sieve_value_t *h, *v; 88 sieve_value_t *h, *v;
89 header_t header = NULL; 89 header_t header = NULL;
90 sieve_comparator_t comp = sieve_get_comparator (tags); 90 sieve_comparator_t comp = sieve_get_comparator (mach, tags);
91 struct address_closure clos; 91 struct address_closure clos;
92 int rc; 92 int rc;
93 93
...@@ -129,7 +129,7 @@ sieve_test_header (sieve_machine_t mach, list_t args, list_t tags) ...@@ -129,7 +129,7 @@ sieve_test_header (sieve_machine_t mach, list_t args, list_t tags)
129 { 129 {
130 sieve_value_t *h, *v; 130 sieve_value_t *h, *v;
131 header_t header = NULL; 131 header_t header = NULL;
132 sieve_comparator_t comp = sieve_get_comparator (tags); 132 sieve_comparator_t comp = sieve_get_comparator (mach, tags);
133 133
134 if (mach->debug_level & MU_SIEVE_DEBUG_TRACE) 134 if (mach->debug_level & MU_SIEVE_DEBUG_TRACE)
135 sieve_debug (mach, "HEADER\n"); 135 sieve_debug (mach, "HEADER\n");
...@@ -147,8 +147,31 @@ sieve_test_header (sieve_machine_t mach, list_t args, list_t tags) ...@@ -147,8 +147,31 @@ sieve_test_header (sieve_machine_t mach, list_t args, list_t tags)
147 sieve_abort (mach); 147 sieve_abort (mach);
148 } 148 }
149 149
150 message_get_header (sieve_get_message (mach), &header); 150 if (sieve_tag_lookup (tags, "mime", NULL))
151 {
152 int ismime = 0;
153
154 message_is_multipart (mach->msg, &ismime);
155 if (ismime)
156 {
157 size_t i, nparts = 0;
151 158
159 message_get_num_parts (mach->msg, &nparts);
160 for (i = 1; i <= nparts; i++)
161 {
162 message_t message = NULL;
163
164 if (message_get_part (mach->msg, i, &message) == 0)
165 {
166 message_get_header (message, &header);
167 if (sieve_vlist_compare (h, v, comp,
168 retrieve_header, header))
169 return 1;
170 }
171 }
172 }
173 }
174 message_get_header (mach->msg, &header);
152 return sieve_vlist_compare (h, v, comp, retrieve_header, header); 175 return sieve_vlist_compare (h, v, comp, retrieve_header, header);
153 } 176 }
154 177
...@@ -184,7 +207,7 @@ int ...@@ -184,7 +207,7 @@ int
184 sieve_test_envelope (sieve_machine_t mach, list_t args, list_t tags) 207 sieve_test_envelope (sieve_machine_t mach, list_t args, list_t tags)
185 { 208 {
186 sieve_value_t *h, *v; 209 sieve_value_t *h, *v;
187 sieve_comparator_t comp = sieve_get_comparator (tags); 210 sieve_comparator_t comp = sieve_get_comparator (mach, tags);
188 struct address_closure clos; 211 struct address_closure clos;
189 int rc; 212 int rc;
190 213
...@@ -305,6 +328,11 @@ static sieve_tag_def_t size_tags[] = { ...@@ -305,6 +328,11 @@ static sieve_tag_def_t size_tags[] = {
305 { NULL } 328 { NULL }
306 }; 329 };
307 330
331 static sieve_tag_def_t mime_tags[] = {
332 { "mime", SVT_VOID },
333 { NULL }
334 };
335
308 #define ADDRESS_PART_GROUP \ 336 #define ADDRESS_PART_GROUP \
309 { address_part_tags, NULL } 337 { address_part_tags, NULL }
310 338
...@@ -313,6 +341,9 @@ static sieve_tag_def_t size_tags[] = { ...@@ -313,6 +341,9 @@ static sieve_tag_def_t size_tags[] = {
313 341
314 #define SIZE_GROUP { size_tags, NULL } 342 #define SIZE_GROUP { size_tags, NULL }
315 343
344 #define MIME_GROUP \
345 { mime_tags, NULL }
346
316 sieve_tag_group_t address_tag_groups[] = { 347 sieve_tag_group_t address_tag_groups[] = {
317 ADDRESS_PART_GROUP, 348 ADDRESS_PART_GROUP,
318 MATCH_PART_GROUP, 349 MATCH_PART_GROUP,
...@@ -348,22 +379,23 @@ sieve_data_type exists_req_args[] = { ...@@ -348,22 +379,23 @@ sieve_data_type exists_req_args[] = {
348 379
349 sieve_tag_group_t header_tag_groups[] = { 380 sieve_tag_group_t header_tag_groups[] = {
350 MATCH_PART_GROUP, 381 MATCH_PART_GROUP,
382 MIME_GROUP,
351 { NULL } 383 { NULL }
352 }; 384 };
353 385
354 void 386 void
355 sieve_register_standard_tests () 387 sieve_register_standard_tests (sieve_machine_t mach)
356 { 388 {
357 sieve_register_test ("false", sieve_test_false, NULL, NULL, 1); 389 sieve_register_test (mach, "false", sieve_test_false, NULL, NULL, 1);
358 sieve_register_test ("true", sieve_test_true, NULL, NULL, 1); 390 sieve_register_test (mach, "true", sieve_test_true, NULL, NULL, 1);
359 sieve_register_test ("address", sieve_test_address, 391 sieve_register_test (mach, "address", sieve_test_address,
360 address_req_args, address_tag_groups, 1); 392 address_req_args, address_tag_groups, 1);
361 sieve_register_test ("size", sieve_test_size, 393 sieve_register_test (mach, "size", sieve_test_size,
362 size_req_args, size_tag_groups, 1); 394 size_req_args, size_tag_groups, 1);
363 sieve_register_test ("envelope", sieve_test_envelope, 395 sieve_register_test (mach, "envelope", sieve_test_envelope,
364 address_req_args, envelope_tag_groups, 1); 396 address_req_args, envelope_tag_groups, 1);
365 sieve_register_test ("exists", sieve_test_exists, 397 sieve_register_test (mach, "exists", sieve_test_exists,
366 exists_req_args, NULL, 1); 398 exists_req_args, NULL, 1);
367 sieve_register_test ("header", sieve_test_header, 399 sieve_register_test (mach, "header", sieve_test_header,
368 address_req_args, header_tag_groups, 1); 400 address_req_args, header_tag_groups, 1);
369 } 401 }
......