Commit 678d9367 678d936783f591bcf7c3f8acafd0152a3c1b0b61 by Sergey Poznyakoff

Minor changes in sieve.

* libmu_sieve/runtime.c (mu_sieve_abort): Jump with code MU_ERR_FAILURE.
* libmu_sieve/tests.c (retrieve_address): Tolerate empty addresses.
(retrieve_header): Return reasonable error code.
* maidag/script.c (script_apply): If the script failed, return 0.
1 parent 6f32dede
......@@ -157,7 +157,7 @@ _mu_i_sv_instr_brnz (mu_sieve_machine_t mach)
void
mu_sieve_abort (mu_sieve_machine_t mach)
{
longjmp (mach->errbuf, 1);
longjmp (mach->errbuf, MU_ERR_FAILURE);
}
void
......
......@@ -67,6 +67,8 @@ retrieve_address (void *item, void *data, size_t idx, char **pval)
rc = mu_header_aget_value ((mu_header_t)ap->data, (char*)item, &val);
if (rc)
return rc;
if (mu_str_skip_class (val, MU_CTYPE_BLANK)[0] == 0)
return MU_ERR_NOENT;
rc = mu_address_create (&ap->addr, val);
free (val);
if (rc)
......@@ -150,11 +152,7 @@ retrieve_header (void *item, void *data, size_t idx, char **pval)
{
int i = hc->index++;
if (mu_c_strcasecmp (hname, (char*)item) == 0)
{
if (mu_header_aget_field_value_unfold (hc->header, i, pval))
return -1;
return 0;
}
return mu_header_aget_field_value_unfold (hc->header, i, pval);
}
hc->header = NULL;
......
......@@ -98,13 +98,6 @@ apply_script (void *item, void *data)
free (progfile);
if (rc == 0)
{
mu_attribute_t attr;
mu_message_get_attribute (clos->msg, &attr);
rc = mu_attribute_is_deleted (attr);
}
return rc;
}
......@@ -129,6 +122,14 @@ script_apply (mu_message_t msg, struct mu_auth_data *auth)
rc = mu_list_foreach (script_list, apply_script, &clos);
chdir ("/");
switch_user_id (auth, 0);
if (rc == 0)
{
mu_attribute_t attr;
mu_message_get_attribute (msg, &attr);
rc = mu_attribute_is_deleted (attr);
}
else
rc = 0;
}
}
return rc;
......