UString Command::mailboxName() { EString n = astring(); if ( n.endsWith( "/" ) ) n = n.mid( 0, n.length() - 1 ); User * u = imap()->user(); if ( u && n.lower() == "inbox" ) { return u->inbox()->name(); } MUtf7Codec m; UString un( m.toUnicode( n ) ); UString r; if ( !m.wellformed() ) { AsciiCodec a; un = a.toUnicode( n ); if ( !a.valid() ) { error( Bad, "Mailbox name misparsed both as ASCII and mUTF-7: " + m.error() + " (mUTF7) + " + a.error() + " (ASCII)" ); return r; } } if ( un.startsWith( "/" ) ) { if ( u && un[u->home()->name().length()] == '/' && un.startsWith( u->home()->name() ) ) d->usesAbsoluteMailbox = true; } else if ( !u ) { error( Bad, "Relative mailbox name is invalid before login" ); return r; } else { d->usesRelativeMailbox = true; r.append( u->home()->name() ); r.append( "/" ); } r.append( un ); if ( !Mailbox::validName( r ) ) { error( Bad, "Syntax error in mailbox name: " + n ); return r; } return r; }
UString Command::listMailbox() { EString r( d->args->listMailbox() ); if ( !d->args->ok() ) error( Bad, d->args->error() ); MUtf7Codec m; UString u( m.toUnicode( r ) ); if ( !m.wellformed() ) { AsciiCodec a; u = a.toUnicode( r ); if ( !a.valid() ) error( Bad, "List-mailbox misparsed both as ASCII and mUTF-7: " + m.error() + " (mUTF7) + " + a.error() + " (ASCII)" ); } return u; }