From: Timo Sirainen Date: Mon, 10 Feb 2025 07:44:12 +0000 (+0200) Subject: imap: Fix ENABLE UTF8=ACCEPT to not return it to client if mail_utf8_extensions=no X-Git-Tag: 2.4.1~230 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=13f23f2c03ec1b0a8020af36896a4cab20a67519;p=thirdparty%2Fdovecot%2Fcore.git imap: Fix ENABLE UTF8=ACCEPT to not return it to client if mail_utf8_extensions=no --- diff --git a/src/imap/cmd-enable.c b/src/imap/cmd-enable.c index 904d6db356..84b9c72c2f 100644 --- a/src/imap/cmd-enable.c +++ b/src/imap/cmd-enable.c @@ -21,8 +21,8 @@ bool cmd_enable(struct client_command_context *cmd) client_send_command_error(cmd, "Invalid arguments."); return TRUE; } - if (imap_feature_lookup(str, &feature_idx)) { - client_enable(cmd->client, feature_idx); + if (imap_feature_lookup(str, &feature_idx) && + client_enable(cmd->client, feature_idx)) { str_append_c(reply, ' '); str_append(reply, t_str_ucase(str)); } diff --git a/src/imap/imap-client.c b/src/imap/imap-client.c index 2bdc984bed..b94624dd44 100644 --- a/src/imap/imap-client.c +++ b/src/imap/imap-client.c @@ -1569,17 +1569,17 @@ bool client_handle_search_save_ambiguity(struct client_command_context *cmd) return TRUE; } -void client_enable(struct client *client, unsigned int feature_idx) +bool client_enable(struct client *client, unsigned int feature_idx) { if (client_has_enabled(client, feature_idx)) - return; + return TRUE; const struct imap_feature *feat = imap_feature_idx(feature_idx); if ((feat->mailbox_features & MAILBOX_FEATURE_UTF8ACCEPT) != 0 && !client->set->mail_utf8_extensions) { e_debug(client->event, "Client attempted to enable UTF8 when it's disabled"); - return; + return FALSE; } feat->callback(client); @@ -1587,6 +1587,7 @@ void client_enable(struct client *client, unsigned int feature_idx) previously set */ bool value = TRUE; array_idx_set(&client->enabled_features, feature_idx, &value); + return TRUE; } bool client_has_enabled(struct client *client, unsigned int feature_idx) diff --git a/src/imap/imap-client.h b/src/imap/imap-client.h index 65b30007d8..e1818b3f14 100644 --- a/src/imap/imap-client.h +++ b/src/imap/imap-client.h @@ -335,7 +335,9 @@ void client_args_finished(struct client_command_context *cmd, have to wait for an existing SEARCH SAVE to finish. */ bool client_handle_search_save_ambiguity(struct client_command_context *cmd); -void client_enable(struct client *client, unsigned int feature_idx); +/* Enable an IMAP feature. Returns TRUE if the feature was actually enabled + (or it was already enabled before). */ +bool client_enable(struct client *client, unsigned int feature_idx); /* Returns TRUE if the given feature is enabled */ bool client_has_enabled(struct client *client, unsigned int feature_idx); /* Returns mailbox features that are currently enabled. */