summaryrefslogtreecommitdiff
path: root/libmu_sieve
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2015-10-25 23:18:36 +0200
committerSergey Poznyakoff <gray@gnu.org>2015-10-25 23:26:00 +0200
commit9a908ba5a87216d24112e36f7f9c7ffbc6dd53a3 (patch)
tree40a683bb2696653d6cd9f233369968fe03ea336c /libmu_sieve
parentdcbf8f353e76d506ecf7ae6c48081783166a82ab (diff)
downloadmailutils-9a908ba5a87216d24112e36f7f9c7ffbc6dd53a3.tar.gz
mailutils-9a908ba5a87216d24112e36f7f9c7ffbc6dd53a3.tar.bz2
Fixes in sieve vacation extension
* libmu_sieve/extensions/vacation.c (build_mime): Fix memory leak. This also flushes the message body stream, so its content becomes visible for the mailer. (noreply_address_p): Rename "addresses" tag to "noreply". (check_db): The "database" tag provides vacation database name. (vacation_reply): Always set message headers. (vacation_tags): Rename "addresses" tag to "noreply". New tag: "database" * sieve/tests/vacation.at: New file. * sieve/tests/Makefile.am (TESTSUITE_AT): Add vacation.at. * sieve/tests/testsuite.at: Include vacation.at. * doc/texinfo/programs.texi: Minor change.
Diffstat (limited to 'libmu_sieve')
-rw-r--r--libmu_sieve/extensions/vacation.c31
1 files changed, 20 insertions, 11 deletions
diff --git a/libmu_sieve/extensions/vacation.c b/libmu_sieve/extensions/vacation.c
index fee207407..067e7726b 100644
--- a/libmu_sieve/extensions/vacation.c
+++ b/libmu_sieve/extensions/vacation.c
@@ -19,10 +19,14 @@
/* Syntax: vacation [:days <ndays: number>]
[:subject <subject: string>]
[:aliases <address-list: list>]
- [:addresses <noreply-address-list: list>]
+ [:noreply <noreply-address-list: list>]
[:reply_regex <expr: string>]
[:reply_prefix <prefix: string>]
- <reply text: string>
+ [:sender <email: string>]
+ [:database <path: string>]
+ [:file]
+ [:mime]
+ <reply: string>
*/
#ifdef HAVE_CONFIG_H
@@ -98,6 +102,9 @@ build_mime (mu_sieve_machine_t mach, mu_list_t tags, mu_mime_t *pmime,
}
rc = mu_stream_copy (stream, input, 0, NULL);
+ mu_stream_destroy (&input);
+ mu_stream_destroy (&stream);
+
if (rc)
{
mu_sieve_error (mach,
@@ -105,13 +112,9 @@ build_mime (mu_sieve_machine_t mach, mu_list_t tags, mu_mime_t *pmime,
mu_strerror (rc));
mu_mime_destroy (&mime);
mu_message_destroy (&newmsg, NULL);
- mu_stream_destroy (&input);
- mu_stream_destroy (&stream);
return 1;
}
- mu_stream_destroy (&input);
-
mu_header_create (&hdr, header, strlen (header));
mu_message_set_header (newmsg, hdr, NULL);
@@ -157,7 +160,7 @@ _compare (void *item, void *data)
/* Check whether an alias from ADDRESSES is part of To: or Cc: headers
of the originating mail. Return non-zero if so and store a pointer
- to the matching address to *MY_ADDRESS. */
+ to the matching address in *MY_ADDRESS. */
static int
match_addresses (mu_header_t hdr, mu_sieve_value_t *addresses,
char **my_address)
@@ -241,7 +244,7 @@ noreply_address_p (mu_sieve_machine_t mach, mu_list_t tags, char *email)
for (i = 0; rc == 0 && noreply_sender[i]; i++)
rc = regex_comparator (noreply_sender[i], &rd);
- if (!rc && mu_sieve_tag_lookup (tags, "addresses", &arg))
+ if (!rc && mu_sieve_tag_lookup (tags, "noreply", &arg))
rc = mu_sieve_vlist_do (arg, regex_comparator, &rd);
return rc;
@@ -338,6 +341,7 @@ check_db (mu_sieve_machine_t mach, mu_list_t tags, char *from)
int rc;
mu_stream_t str;
mu_locker_t locker;
+ const char *dbfile = "~/.vacation";
if (mu_sieve_tag_lookup (tags, "days", &arg))
{
@@ -348,7 +352,10 @@ check_db (mu_sieve_machine_t mach, mu_list_t tags, char *from)
else
days = DAYS_DEFAULT;
- file = mu_tilde_expansion ("~/.vacation", MU_HIERARCHY_DELIMITER, NULL);
+ if (mu_sieve_tag_lookup (tags, "database", &arg))
+ dbfile = arg->v.string;
+
+ file = mu_tilde_expansion (dbfile, MU_HIERARCHY_DELIMITER, NULL);
if (!file)
{
mu_sieve_error (mach, _("%lu: cannot build db file name"),
@@ -563,9 +570,10 @@ vacation_reply (mu_sieve_machine_t mach, mu_list_t tags, mu_message_t msg,
return -1;
mu_mime_get_message (mime, &newmsg);
mu_message_unref (newmsg);
- mu_message_get_header (newmsg, &newhdr);
}
+ mu_message_get_header (newmsg, &newhdr);
+
rc = mu_address_create (&to_addr, to);
if (rc)
{
@@ -685,10 +693,11 @@ static mu_sieve_tag_def_t vacation_tags[] = {
{"days", SVT_NUMBER},
{"subject", SVT_STRING},
{"aliases", SVT_STRING_LIST},
- {"addresses", SVT_STRING_LIST},
+ {"noreply", SVT_STRING_LIST},
{"reply_regex", SVT_STRING},
{"reply_prefix", SVT_STRING},
{"sender", SVT_STRING},
+ {"database", SVT_STRING},
{"mime", SVT_VOID},
{"file", SVT_VOID},
{NULL}

Return to:

Send suggestions and report system problems to the System administrator.