Commit 09105467 091054679e9842c2b96b3ee7e4ff5b59f8e0f9ee by Sergey Poznyakoff

Fix listing names with escapable characters

* imap4d/io.c (io_send_qstring): Fix condition
* imap4d/list.c (list_fun): Use io_send_qstring to print names.
* imap4d/lsub.c (imap4d_lsub): Likewise.
1 parent 50979073
......@@ -234,15 +234,14 @@ io_sendf (const char *format, ...)
}
/* Send NIL if empty string, change the quoted string to a literal if the
string contains: double quotes, CR, LF, and '/'. CR, LF will be changed
string contains: double quotes, CR, LF, and '\\'. CR, LF will be changed
to spaces. */
int
io_send_qstring (const char *buffer)
{
if (buffer == NULL || *buffer == '\0')
return io_sendf ("NIL");
if (strchr (buffer, '"') || strchr (buffer, '\r') || strchr (buffer, '\n')
|| strchr (buffer, '\\'))
if (strpbrk (buffer, "\"\r\n\\"))
{
char *s;
int ret;
......
......@@ -93,7 +93,10 @@ list_fun (mu_folder_t folder, struct mu_list_response *resp, void *data)
else if (is_atom (name))
io_sendf ("%s\n", name);
else
io_sendf ("\"%s\"\n", name);
{
io_send_qstring (name);
io_sendf ("\n", name);
}
return 0;
}
......
......@@ -65,8 +65,12 @@ imap4d_lsub (struct imap4d_session *session,
mu_iterator_current_kv (itr, (const void **)&name, (void**)&val);
if (mu_imap_wildmatch (pattern, name, MU_HIERARCHY_DELIMITER) == 0)
io_untagged_response (RESP_NONE, "LSUB () \"%c\" \"%s\"",
MU_HIERARCHY_DELIMITER, name);
{
mu_stream_printf (iostream, "* LSUB () \"%c\" ",
MU_HIERARCHY_DELIMITER);
io_send_qstring (name);
io_sendf ("\n");
}
}
}
else
......