diff options
author | Sergey Poznyakoff <gray@gnu.org> | 2021-06-06 20:13:44 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org> | 2021-06-06 21:11:10 +0300 |
commit | b6818d6d3c2078b595453f982996090de7619ebc (patch) | |
tree | 707e194d399fb0e85f18caf0f7f77974469c6c09 /libmailutils | |
parent | 8530aa4dfe372948c9d1b2e01be0697057589eb5 (diff) | |
download | mailutils-b6818d6d3c2078b595453f982996090de7619ebc.tar.gz mailutils-b6818d6d3c2078b595453f982996090de7619ebc.tar.bz2 |
mail: revamp parsing of adresses in send mode
In particular, this fixes parsing of addresses with comma in the local
part.
* include/mailutils/address.h (MU_ADDRESS_HINT_INITIALIZER): New define.
* libmailutils/address/addrstream.c (mu_stream_format_address): Format
local user names without surrounding angle quotes.
* mail/mail.h (util_header_expand): Rename to util_header_expand_aliases.
All uses changed.
(util_address_expand_aliases): New function.
* mail/send.c (compose_header_set): Expand aliases if inplacealiases
is set.
Avoid useless recursion.
* mail/util.c (send_message): Create addresses via mu_address_create_hint
to avoid appending local domain to the unqualified user names.
(mail_send0): Likewise.
(util_address_expand_aliases): New function.
(util_header_expand): Rename to util_header_expand_aliases. Use
util_address_expand_aliases and regular address parsing functions
instead of wordsplit. Unwrap header values.
Diffstat (limited to 'libmailutils')
-rw-r--r-- | libmailutils/address/addrstream.c | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/libmailutils/address/addrstream.c b/libmailutils/address/addrstream.c index 4bcf181ed..0fbaad28a 100644 --- a/libmailutils/address/addrstream.c +++ b/libmailutils/address/addrstream.c @@ -19,6 +19,7 @@ # include <config.h> #endif #include <stdlib.h> +#include <string.h> #include <mailutils/address.h> #include <mailutils/stream.h> @@ -37,23 +38,34 @@ mu_stream_format_address (mu_stream_t str, mu_address_t addr) if (comma) mu_stream_write (str, ",", 1, NULL); - if (addr->personal) + if (!addr->personal && + !addr->comments && + !addr->domain && + !addr->route) { - mu_stream_printf (str, "\"%s\"", addr->personal); - space++; + /* Local user name: print as is */ + mu_stream_write (str, addr->email, strlen (addr->email), NULL); } - - if (addr->comments) + else { + if (addr->personal) + { + mu_stream_printf (str, "\"%s\"", addr->personal); + space++; + } + + if (addr->comments) + { + if (space) + mu_stream_write (str, " ", 1, NULL); + mu_stream_printf (str, "(%s)", addr->comments); + space++; + } + if (space) mu_stream_write (str, " ", 1, NULL); - mu_stream_printf (str, "(%s)", addr->comments); - space++; + mu_stream_printf (str, "<%s>", addr->email); } - - if (space) - mu_stream_write (str, " ", 1, NULL); - mu_stream_printf (str, "<%s>", addr->email); comma++; } } |