From 877ba2900ac42f6b0c4edaf68a4be9c1bd54ae72 Mon Sep 17 00:00:00 2001 From: Stephan Bosch <stephan@rename-it.nl> Date: Sat, 27 Dec 2008 22:43:33 +0100 Subject: [PATCH] Enotify: added check for duplicate recipients within URI. --- src/lib-sieve/plugins/enotify/ntfy-mailto.c | 27 ++++++++++++++++----- 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/src/lib-sieve/plugins/enotify/ntfy-mailto.c b/src/lib-sieve/plugins/enotify/ntfy-mailto.c index c67506cf4..2608cbe70 100644 --- a/src/lib-sieve/plugins/enotify/ntfy-mailto.c +++ b/src/lib-sieve/plugins/enotify/ntfy-mailto.c @@ -211,9 +211,11 @@ static bool _parse_hex_value(const char **in, char *out) } static bool _uri_add_valid_recipient -(const struct sieve_enotify_log *nlog, ARRAY_TYPE(recipients) *recipients_r, +(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; @@ -223,13 +225,26 @@ static bool _uri_add_valid_recipient str_sanitize(str_c(recipient), 80), error); return FALSE; } - + /* Add recipient to the list */ - if ( recipients_r != NULL ) { - pool_t pool = array_get_pool(recipients_r); + if ( recipients != NULL ) { + pool_t pool; struct ntfy_mailto_recipient *new_recipient; - - new_recipient = array_append_space(recipients_r); + + /* Check for duplicate first */ + rcpts = array_get(recipients, &count); + for ( i = 0; i < count; i++ ) { + if ( strcmp(rcpts[i].normalized, normalized) == 0 ) { + sieve_enotify_warning(nlog, + "mailto URI: ignored duplicate recipient '%s'", + str_sanitize(str_c(recipient), 80)); + return TRUE; + } + } + + /* Add */ + pool = array_get_pool(recipients); + new_recipient = array_append_space(recipients); new_recipient->carbon_copy = cc; new_recipient->full = p_strdup(pool, str_c(recipient)); new_recipient->normalized = p_strdup(pool, normalized); -- GitLab