Greetings -
On 9 Mar 2007, at 19:40, Timo Sirainen wrote:
I don't see any other way of doing this. Except possibly to give
"invalid mailbox name" errors, or maybe even change the dot
silently to
some other character. All of these options kind of suck.
We've been discussing this problem here and feel that for our users
asking for a folder "M.Brudenell" but being given folder "M"
containing folder "Brudenell" is going to be too unexpected.
Instead we'd like to either reject attempts to create a folder
containing ".", or else silently change the "." to another single
character (eg, "_"). We haven't decided which yet, but probably the
former.
I've been trying to find my way around the Dovecot source (a new
package is _such_ an adventure! :-) and I *think* the place for us to
bolt such a check in is here:
File: src/imap/commands-util.c
Function: client_verify_mailbox_name()
Currently this contains various checks including one like this:
/* 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) {
client_send_tagline(cmd, "NO Invalid mailbox
name.");
return FALSE;
}
}
I was thinking of preceding this with something along the lines of
this (UNTESTED) code fragment:
/* if the separator isn't '.' then don't allow '.' in folder
names */
if (sep != '.') {
for (p = mailbox; *p != '\0'; p++) {
if (p[0] == '.') {
client_send_tagline(cmd, "NO Full-stop not
allowed in mailbox name.");
return FALSE;
}
}
}
Does something like this look OK?
And should it be sufficient? (ie, is this the only place I would
need to insert such a test, or are there other files/functions that
would need it too?)
===================================
By the way...
Timo: I may have spotted another instance of a mailbox name being
returned using the wrong hierarchy separator character (in Dovecot
1.0rc24 with separator set to "/"). Here:
a01 login pmb1 secretpassword
a01 OK Logged in.
a02 select a//b <========================== Asked with //
a02 NO Mailbox doesn't exist: a..b <============ Reply with ..
a03 select a..b
a03 NO Mailbox doesn't exist: a..b
a04 create a..b
a04 NO Invalid mailbox name.
a05 create a//b
a05 NO Invalid mailbox name.
a06 logout
* BYE Logging out
a06 OK Logout completed.
And also...
I'm confused how client_verify_mailbox_name() is detecting two or
more of either "." or "/" as the code looks to only check one
separator character (obtained from mail_storage_get_hierarchy_sep
(storage))
Or is this returning the separator character maildir is using (".")
and not the hierarchy separator which we have changed in the Dovecot
configuration file to "/"? If so then my code fragment isn't going
to work, as the Maildir filestore separator will continue to be "." :-(
Help! I'm confused now!
Cheers,
Mike B-)
--
The Computing Service, University of York, Heslington, York Yo10 5DD, UK
Tel:+44-1904-433811 FAX:+44-1904-433740
* Unsolicited commercial e-mail is NOT welcome at this e-mail address. *