summaryrefslogtreecommitdiff
path: root/libmu_sieve/extensions/moderator.c
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2017-04-17 15:33:12 +0300
committerSergey Poznyakoff <gray@gnu.org.ua>2017-04-18 19:00:32 +0300
commit27aae941c77f38392a1b058ce8fb04241c143331 (patch)
treece4dce20c44837c5be0c004fefcd931089a88c50 /libmu_sieve/extensions/moderator.c
parentc010cf73e93cbd46a89ef3a6e76a836974bb736b (diff)
downloadmailutils-27aae941c77f38392a1b058ce8fb04241c143331.tar.gz
mailutils-27aae941c77f38392a1b058ce8fb04241c143331.tar.bz2
Fix semantics of mu_header_set_value and creation of multipart/alternative MIME
Until now, mu_header_set_value called with replace=0 prepended the header to the header list, if a header with such name was already present. This has been changed. Now, if the header with the requested name is already present, its action is as follows: 1. If repl is 0, return MU_ERR_EXISTS 2. Otherwise, replace the header with the new value. If the header is not present, it is appended to the end of the header list, instead of putting it at the beginning. This change is incompatible and breaks the tests, that relied on a particular field ordering. These are fixed as well. The use of mu_header_set_value throughout the sources has been revised to ensure that single-instance headers are never added twice. This change also facilitates the second part of this commit, which fixes creation of the multipart/alternative message by the mail utility. * libmailutils/mailbox/header.c (mu_header_set_value): Fix semantics. If the replace parameter is not set and the header field with the given name already exists, return MU_ERR_EXISTS without changing anything. If adding new header, append it to the end of the header list, instead of pushing it to the top. * configure.ac: Raise shared library revision number. * libmu_scm/mu_message.c (mu-message-set-header) (mu-message-set-header-fields): call mu_header_set_value explicitly if repl is not set. * libmu_sieve/extensions/moderator.c: Force replace header mode when needed. * libmu_sieve/extensions/vacation.c: Likewise. * mh/mh_init.c (mh_annotate): Prepend the annotation header. * mh/mhn.c: Force replace header mode when needed. * mh/repl.c: Likewise. * mh/send.c: Likewise. * libmailutils/tests/modmesg01.at: Change expected header order. * libmailutils/tests/modmesg03.at: Likewise. * mh/tests/mhn.at: Likewise. * mh/tests/send.at: Likewise. * sieve/tests/moderator.at: Likewise. * sieve/tests/redirect.at: Likewise. * sieve/tests/reject.at: Likewise. * sieve/tests/vacation.at: Likewise. * examples/mta.c (message_finalize): Append X-Authentication-Warning, instead of setting it. Make sure Content-Disposition is not set for parts of a multipart/ alternative MIME message. Some mail readers (notably, yahoo), misinterpret it. * libmailutils/mime/attachment.c (at_hdr): Use mu_header_set_value to set Content-Type and Content-Disposition. * libmailutils/mime/mime.c (_mime_set_content_type): If the content type is set to multipart/alternative, remove the Content-Disposition headers from the message parts. * mail/send.c (saveatt): Don't set content-disposition for multipart/alternative, it is now done by the library. (add_attachments): Warn about ignored headers. Append only Received and X-* headers, replace others. (parse_headers): Append headers. (compose_header_set): Use mu_header_append if COMPOSE_APPEND is requested. * mail/util.c (util_header_expand): Use mu_header_append.
Diffstat (limited to 'libmu_sieve/extensions/moderator.c')
-rw-r--r--libmu_sieve/extensions/moderator.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/libmu_sieve/extensions/moderator.c b/libmu_sieve/extensions/moderator.c
index 163e7e4fb..5ec61d2f4 100644
--- a/libmu_sieve/extensions/moderator.c
+++ b/libmu_sieve/extensions/moderator.c
@@ -140,6 +140,9 @@ moderator_filter_message (mu_sieve_machine_t mach,
return rc;
}
+/* Copy the value of the header field FROM from the email header FROM_HDR to
+ the header field TO in the header TO_HDR, replacing the field, if it
+ exists. */
static int
copy_header (mu_sieve_machine_t mach,
mu_header_t to_hdr, char *to, mu_header_t from_hdr, char *from)
@@ -153,7 +156,7 @@ copy_header (mu_sieve_machine_t mach,
from, mu_strerror (rc));
return rc;
}
- rc = mu_header_set_value (to_hdr, to, value, 0);
+ rc = mu_header_set_value (to_hdr, to, value, 1);
return rc;
}
@@ -193,7 +196,7 @@ moderator_discard_message (mu_sieve_machine_t mach, mu_message_t request,
}
if (from)
- mu_header_set_value (repl_hdr, MU_HEADER_FROM, from, 0);
+ mu_header_set_value (repl_hdr, MU_HEADER_FROM, from, 1);
mailer = mu_sieve_get_mailer (mach);
rc = mu_mailer_open (mailer, 0);

Return to:

Send suggestions and report system problems to the System administrator.