static void cmd_id_handle_keyvalue(struct imap_client *client, const char *key, const char *value) { if (client->common.trusted && !client->id_logged) client_update_info(client, key, value); if (client->cmd_id->log_reply != NULL && (client->cmd_id->log_keys == NULL || str_array_icase_find((void *)client->cmd_id->log_keys, key))) imap_id_log_reply_append(client->cmd_id->log_reply, key, value); }
const char *imap_id_args_get_log_reply(const struct imap_arg *args, const char *settings) { const char *const *keys, *key, *value; string_t *reply; bool log_all; if (settings == NULL || *settings == '\0') return NULL; if (!imap_arg_get_list(args, &args)) return NULL; log_all = strcmp(settings, "*") == 0; reply = t_str_new(256); keys = t_strsplit_spaces(settings, " "); while (!IMAP_ARG_IS_EOL(&args[0]) && !IMAP_ARG_IS_EOL(&args[1])) { if (!imap_arg_get_string(args, &key)) { /* broken input */ args += 2; continue; } args++; if (strlen(key) > 30) { /* broken: ID spec requires fields to be max. 30 octets */ args++; continue; } if (log_all || str_array_icase_find(keys, key)) { if (!imap_arg_get_nstring(args, &value)) value = ""; imap_id_log_reply_append(reply, key, value); } args++; } return str_len(reply) == 0 ? NULL : str_c(reply); }