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.
Showing
22 changed files
with
174 additions
and
130 deletions
This diff is collapsed.
Click to expand it.
-
Please register or sign in to post a comment