From ec0368c2da9d98c7a81a07d223edb22adbd29eb3 Mon Sep 17 00:00:00 2001
From: Stephan Bosch <stephan@rename-it.nl>
Date: Sat, 27 Dec 2008 22:47:45 +0100
Subject: [PATCH] Enotify: previous change did not distinguish Cc recipients.

---
 src/lib-sieve/plugins/enotify/ntfy-mailto.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/src/lib-sieve/plugins/enotify/ntfy-mailto.c b/src/lib-sieve/plugins/enotify/ntfy-mailto.c
index 2608cbe70..05f9ad590 100644
--- a/src/lib-sieve/plugins/enotify/ntfy-mailto.c
+++ b/src/lib-sieve/plugins/enotify/ntfy-mailto.c
@@ -214,8 +214,6 @@ static bool _uri_add_valid_recipient
 (const struct sieve_enotify_log *nlog, ARRAY_TYPE(recipients) *recipients, 
 	string_t *recipient, bool cc)
 {
-	const struct ntfy_mailto_recipient *rcpts;
-	unsigned int count, i;
 	const char *error;
 	const char *normalized;
 	 
@@ -228,13 +226,18 @@ static bool _uri_add_valid_recipient
 					
 	/* Add recipient to the list */
 	if ( recipients != NULL ) {
-		pool_t pool;
 		struct ntfy_mailto_recipient *new_recipient;
+		struct ntfy_mailto_recipient *rcpts;
+		unsigned int count, i;
+		pool_t pool;
 		
 		/* Check for duplicate first */
-		rcpts = array_get(recipients, &count);
+		rcpts = array_get_modifiable(recipients, &count);
 		for ( i = 0; i < count; i++ ) {
 			if ( strcmp(rcpts[i].normalized, normalized) == 0 ) {
+				/* Upgrade existing Cc: recipient to a To: recipient if possible */
+				rcpts[i].carbon_copy = ( rcpts[i].carbon_copy && cc );
+				
 				sieve_enotify_warning(nlog, 
 					"mailto URI: ignored duplicate recipient '%s'",
 					str_sanitize(str_c(recipient), 80));
-- 
GitLab