From: Timo Sirainen Date: Tue, 9 Jan 2018 21:01:42 +0000 (-0500) Subject: imap-login: Simplify ID handling code X-Git-Tag: 2.3.9~2541 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5329bb264c32fa887e53063ff53272160cb8d7e8;p=thirdparty%2Fdovecot%2Fcore.git imap-login: Simplify ID handling code --- diff --git a/src/imap-login/imap-login-cmd-id.c b/src/imap-login/imap-login-cmd-id.c index ba848ecc17..cbf1d8e593 100644 --- a/src/imap-login/imap-login-cmd-id.c +++ b/src/imap-login/imap-login-cmd-id.c @@ -98,21 +98,20 @@ imap_id_param_handler_find(const char *key) } static bool -client_update_info(struct imap_client *client, - const char *key, const char *value) +client_try_update_info(struct imap_client *client, + const char *key, const char *value) { const struct imap_id_param_handler *handler; handler = imap_id_param_handler_find(key); if (handler == NULL) return FALSE; - handler->callback(client, key, value); - return TRUE; -} -static bool client_id_reserved_word(const char *key) -{ - return imap_id_param_handler_find(key) != NULL; + /* do not try to process NIL values as client-info, + but store them for non-reserved keys */ + if (client->common.trusted && !client->id_logged && value != NULL) + handler->callback(client, key, value); + return TRUE; } static void cmd_id_handle_keyvalue(struct imap_client *client, @@ -124,18 +123,7 @@ static void cmd_id_handle_keyvalue(struct imap_client *client, size_t kvlen = strlen(key) + 2 + 1 + (value == NULL ? 3 : strlen(value)) + 2; - if (client->common.trusted && !client->id_logged) { - if (value == NULL) { - /* do not try to process NIL values as client-info, - but store them for non-reserved keys */ - client_id_str = !client_id_reserved_word(key); - } else { - client_id_str = !client_update_info(client, key, value); - i_assert(client_id_str == !client_id_reserved_word(key)); - } - } else { - client_id_str = !client_id_reserved_word(key); - } + client_id_str = !client_try_update_info(client, key, value); if (client->set->imap_id_retain && client_id_str && (client->common.client_id == NULL ||