# HG changeset patch # User Timo Sirainen # Date 1150552965 -10800 # Node ID 3e74b2b09ed13116e01531268592027df1cfb809 # Parent 5cbabd4ccd9c3a10c38752079d60d5d914a3c80b 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. diff -r 5cbabd4ccd9c -r 3e74b2b09ed1 src/imap/commands-util.c --- 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: