diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2017-04-17 15:33:12 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2017-04-18 19:00:32 +0300 |
commit | 27aae941c77f38392a1b058ce8fb04241c143331 (patch) | |
tree | ce4dce20c44837c5be0c004fefcd931089a88c50 /libmu_sieve | |
parent | c010cf73e93cbd46a89ef3a6e76a836974bb736b (diff) | |
download | mailutils-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')
-rw-r--r-- | libmu_sieve/extensions/moderator.c | 7 | ||||
-rw-r--r-- | libmu_sieve/extensions/vacation.c | 6 |
2 files changed, 8 insertions, 5 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); diff --git a/libmu_sieve/extensions/vacation.c b/libmu_sieve/extensions/vacation.c index 9ac42a9bd..ce199760e 100644 --- a/libmu_sieve/extensions/vacation.c +++ b/libmu_sieve/extensions/vacation.c @@ -513,10 +513,10 @@ vacation_subject (mu_sieve_machine_t mach, if (mu_rfc2047_encode (MU_SIEVE_CHARSET, "quoted-printable", subject, &value)) - mu_header_set_value (newhdr, MU_HEADER_SUBJECT, subject, 0); + mu_header_set_value (newhdr, MU_HEADER_SUBJECT, subject, 1); else { - mu_header_set_value (newhdr, MU_HEADER_SUBJECT, value, 0); + mu_header_set_value (newhdr, MU_HEADER_SUBJECT, value, 1); free (value); } @@ -714,7 +714,7 @@ vacation_reply (mu_sieve_machine_t mach, mu_message_t msg, } else { - mu_header_set_value (newhdr, MU_HEADER_TO, to, 0); + mu_header_set_value (newhdr, MU_HEADER_TO, to, 1); val = mu_sieve_get_tag_untyped (mach, "header"); if (val) |