Mercurial > dovecot > original-hg > dovecot-1.2
changeset 4398:3e74b2b09ed1 HEAD
Fixes to checking if mailbox name is valid. In case mailbox name is invalid,
put it through str_sanitize() before giving it in an error message.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Sat, 17 Jun 2006 17:02:45 +0300 |
parents | 5cbabd4ccd9c |
children | 932a70c17a48 |
files | src/imap/commands-util.c |
diffstat | 1 files changed, 7 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/src/imap/commands-util.c Sat Jun 17 16:55:30 2006 +0300 +++ b/src/imap/commands-util.c Sat Jun 17 17:02:45 2006 +0300 @@ -4,6 +4,7 @@ #include "array.h" #include "buffer.h" #include "str.h" +#include "str-sanitize.h" #include "mail-storage.h" #include "commands-util.h" #include "imap-parser.h" @@ -45,14 +46,14 @@ /* make sure it even looks valid */ sep = mail_storage_get_hierarchy_sep(storage); - if (*mailbox == '\0' || strspn(mailbox, "\r\n*%?") != 0) { - client_send_tagline(cmd, "NO Invalid mailbox name."); + if (*mailbox == '\0') { + client_send_tagline(cmd, "NO Empty mailbox name."); return FALSE; } /* make sure two hierarchy separators aren't next to each others */ for (p = mailbox+1; *p != '\0'; p++) { - if (p[0] == sep && p[1] == sep) { + if (p[0] == sep && p[-1] == sep) { client_send_tagline(cmd, "NO Invalid mailbox name."); return FALSE; } @@ -84,12 +85,13 @@ client_send_tagline(cmd, t_strconcat( "NO [TRYCREATE] Mailbox doesn't exist: ", - mailbox, NULL)); + str_sanitize(mailbox, MAILBOX_MAX_NAME_LEN), NULL)); break; case MAILBOX_NAME_INVALID: client_send_tagline(cmd, t_strconcat( - "NO Invalid mailbox name: ", mailbox, NULL)); + "NO Invalid mailbox name: ", + str_sanitize(mailbox, MAILBOX_MAX_NAME_LEN), NULL)); break; case MAILBOX_NAME_NOINFERIORS: