mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-11-24 20:08:10 +01:00
cli/reply: do not parse Reply-To: header into internet address list twice
Avoid parsing Reply-To: header into internet address list twice. Move the parsing outside of reply_to_header_is_redundant(), and pass the parsed internet address list in as parameter. This also avoids leaking the memory of one copy of the internet address list.
This commit is contained in:
parent
536b1f9df9
commit
932c0ff879
1 changed files with 12 additions and 8 deletions
|
@ -231,19 +231,18 @@ scan_address_list (InternetAddressList *list,
|
||||||
* in either the 'To' or 'Cc' header of the message?
|
* in either the 'To' or 'Cc' header of the message?
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
reply_to_header_is_redundant (notmuch_message_t *message, const char *reply_to)
|
reply_to_header_is_redundant (notmuch_message_t *message,
|
||||||
|
InternetAddressList *reply_to_list)
|
||||||
{
|
{
|
||||||
const char *to, *cc, *addr;
|
const char *to, *cc, *addr;
|
||||||
InternetAddressList *list;
|
|
||||||
InternetAddress *address;
|
InternetAddress *address;
|
||||||
InternetAddressMailbox *mailbox;
|
InternetAddressMailbox *mailbox;
|
||||||
|
|
||||||
list = internet_address_list_parse_string (reply_to);
|
if (reply_to_list == NULL ||
|
||||||
|
internet_address_list_length (reply_to_list) != 1)
|
||||||
if (internet_address_list_length (list) != 1)
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
address = internet_address_list_get_address (list, 0);
|
address = internet_address_list_get_address (reply_to_list, 0);
|
||||||
if (INTERNET_ADDRESS_IS_GROUP (address))
|
if (INTERNET_ADDRESS_IS_GROUP (address))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -269,6 +268,8 @@ static InternetAddressList *get_sender(notmuch_message_t *message,
|
||||||
|
|
||||||
reply_to = g_mime_message_get_reply_to (mime_message);
|
reply_to = g_mime_message_get_reply_to (mime_message);
|
||||||
if (reply_to && *reply_to) {
|
if (reply_to && *reply_to) {
|
||||||
|
InternetAddressList *reply_to_list;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Some mailing lists munge the Reply-To header despite it
|
* Some mailing lists munge the Reply-To header despite it
|
||||||
* being A Bad Thing, see
|
* being A Bad Thing, see
|
||||||
|
@ -282,8 +283,11 @@ static InternetAddressList *get_sender(notmuch_message_t *message,
|
||||||
* to the list. Note that the address in the Reply-To header
|
* to the list. Note that the address in the Reply-To header
|
||||||
* will always appear in the reply if reply_all is true.
|
* will always appear in the reply if reply_all is true.
|
||||||
*/
|
*/
|
||||||
if (! reply_to_header_is_redundant (message, reply_to))
|
reply_to_list = internet_address_list_parse_string (reply_to);
|
||||||
return internet_address_list_parse_string (reply_to);
|
if (! reply_to_header_is_redundant (message, reply_to_list))
|
||||||
|
return reply_to_list;
|
||||||
|
|
||||||
|
g_object_unref (G_OBJECT (reply_to_list));
|
||||||
}
|
}
|
||||||
|
|
||||||
return internet_address_list_parse_string (
|
return internet_address_list_parse_string (
|
||||||
|
|
Loading…
Reference in a new issue