]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/IMAPD.pm
imap: omit $UID_END from mailbox name, use index
[public-inbox.git] / lib / PublicInbox / IMAPD.pm
index b647c94050512007132da6df9e84d620d360d501..261d756042fbf7ee2856e486d11e28c46b3202e4 100644 (file)
@@ -31,7 +31,7 @@ sub imapd_refresh_ibx { # pi_config->each_inbox cb
                        join(', ', @$ngname). "\n";
                return;
        } elsif ($ngname =~ m![^a-z0-9/_\.\-\~\@\+\=:]! ||
-                $ngname =~ /\.[0-9]+-[0-9]+\z/) {
+                $ngname =~ /\.[0-9]+\z/) {
                warn "mailbox name invalid: newsgroup=`$ngname'\n";
                return;
        }
@@ -72,7 +72,12 @@ sub imapd_refresh_finalize {
                map {
                        my $no = $mailboxes->{$_} == $dummy ? '' : 'No';
                        qq[* LIST (\\Has${no}Children) "." $_\r\n]
-               } sort { length($a) <=> length($b) } keys %$mailboxes
+               } sort {
+                       # shortest names first, alphabetically if lengths match
+                       length($a) == length($b) ?
+                               ($a cmp $b) :
+                               (length($a) <=> length($b))
+               } keys %$mailboxes
        ];
        $imapd->{pi_config} = $pi_config;
        if (my $idler = $imapd->{idler}) {