Don't allow mailboxes named "." or ".." and normalize names during imports too

It only serves to confuse. When exporting such mailboxes in zip files or tar
files, extracting will cause trouble.
This commit is contained in:
Mechiel Lukkien
2025-03-05 22:28:25 +01:00
parent 7872b138a5
commit e572d01341
4 changed files with 36 additions and 10 deletions

View File

@ -16,6 +16,8 @@ import (
"strings"
"time"
"golang.org/x/text/unicode/norm"
"github.com/mjl-/mox/config"
"github.com/mjl-/mox/message"
"github.com/mjl-/mox/metrics"
@ -189,6 +191,11 @@ func importctl(ctx context.Context, ctl *ctl, mbox bool) {
var mdnewf, mdcurf *os.File
var msgreader store.MsgSource
// Ensure normalized form.
mailbox = norm.NFC.String(mailbox)
mailbox, _, err = store.CheckMailboxName(mailbox, true)
ctl.xcheck(err, "checking mailbox name")
// Open account, creating a database file if it doesn't exist yet. It must be known
// in the configuration file.
a, err := store.OpenAccount(ctl.log, account, false)