about summary refs log tree commit homepage
path: root/lib/PublicInbox
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2023-11-14 00:32:20 +0000
committerEric Wong <e@80x24.org>2023-11-14 20:08:08 +0000
commit0e2b20d6eb0754426d021d8db1fb8db7584dd925 (patch)
treeca5bb354e948ed079cb104fbeab875dd57cf9fcc /lib/PublicInbox
parent69c0b8ece354146649112268935d4db6b2cb7964 (diff)
downloadpublic-inbox-0e2b20d6eb0754426d021d8db1fb8db7584dd925.tar.gz
Start lowercasing newsgroup names automatically since uppercase
names are incompatible with IMAP and POP3 and also causes
problems with both -extindex and -cindex.

We'll also warn on eidx_key and newsgroup conflicts to avoid
sometimes subtle breakage when using -extindex and -cindex.
Diffstat (limited to 'lib/PublicInbox')
-rw-r--r--lib/PublicInbox/Config.pm14
-rw-r--r--lib/PublicInbox/IMAPD.pm9
2 files changed, 14 insertions, 9 deletions
diff --git a/lib/PublicInbox/Config.pm b/lib/PublicInbox/Config.pm
index 01cb536d..9bee94b8 100644
--- a/lib/PublicInbox/Config.pm
+++ b/lib/PublicInbox/Config.pm
@@ -509,9 +509,16 @@ sub _fill_ibx {
                         delete $ibx->{newsgroup};
                         warn "newsgroup name invalid: `$ngname'\n";
                 } else {
+                        my $lc = $ibx->{newsgroup} = lc $ngname;
+                        warn <<EOM if $lc ne $ngname;
+W: newsgroup=`$ngname' lowercased to `$lc'
+EOM
                         # PublicInbox::NNTPD does stricter ->nntp_usable
                         # checks, keep this lean for startup speed
-                        $self->{-by_newsgroup}->{$ngname} = $ibx;
+                        my $cur = $self->{-by_newsgroup}->{$lc} //= $ibx;
+                        warn <<EOM if $cur != $ibx;
+W: newsgroup=`$lc' is used by both `$cur->{name}' and `$ibx->{name}'
+EOM
                 }
         }
         unless (defined $ibx->{newsgroup}) { # for ->eidx_key
@@ -531,7 +538,10 @@ sub _fill_ibx {
                 require PublicInbox::Isearch;
                 $ibx->{isrch} = PublicInbox::Isearch->new($ibx, $es);
         }
-        $self->{-by_eidx_key}->{$ibx->eidx_key} = $ibx;
+        my $cur = $self->{-by_eidx_key}->{my $ekey = $ibx->eidx_key} //= $ibx;
+        $cur == $ibx or warn
+                "W: `$ekey' used by both `$cur->{name}' and `$ibx->{name}'\n";
+        $ibx;
 }
 
 sub _fill_ei ($$) {
diff --git a/lib/PublicInbox/IMAPD.pm b/lib/PublicInbox/IMAPD.pm
index bdadb7a3..42dc2a9f 100644
--- a/lib/PublicInbox/IMAPD.pm
+++ b/lib/PublicInbox/IMAPD.pm
@@ -27,13 +27,8 @@ sub _refresh_ibx { # pi_cfg->each_inbox cb
         my ($ibx, $imapd, $cache, $dummies) = @_;
         my $ngname = $ibx->{newsgroup} // return;
 
-        # We require lower-case since IMAP mailbox names are
-        # case-insensitive (but -nntpd matches INN in being
-        # case-sensitive)
-        if ($ngname =~ m![^a-z0-9/_\.\-\~\@\+\=:]! ||
-                        # don't confuse with 50K slices
-                        $ngname =~ /\.[0-9]+\z/) {
-                warn "mailbox name invalid: newsgroup=`$ngname'\n";
+        if ($ngname =~ /\.[0-9]+\z/) { # don't confuse with 50K slices
+                warn "E: mailbox name invalid: newsgroup=`$ngname' (ignored)\n";
                 return;
         }
         my $ce = $cache->{$ngname};