diff options
author | Eric Wong <e@80x24.org> | 2023-11-14 00:32:20 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2023-11-14 20:08:08 +0000 |
commit | 0e2b20d6eb0754426d021d8db1fb8db7584dd925 (patch) | |
tree | ca5bb354e948ed079cb104fbeab875dd57cf9fcc /t | |
parent | 69c0b8ece354146649112268935d4db6b2cb7964 (diff) | |
download | public-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 't')
-rw-r--r-- | t/config.t | 35 | ||||
-rw-r--r-- | t/imap.t | 13 |
2 files changed, 40 insertions, 8 deletions
@@ -299,4 +299,37 @@ my $re = $glob2re->('a/**/b'); is_deeply($re, 'a/.*?b', 'double asterisk middle'); like($_, qr!$re!, "a/**/b matches $_") for ('a/b', 'a/c/b', 'a/c/a/b'); -done_testing(); +{ + my $w = ''; + local $SIG{__WARN__} = sub { $w .= "@_"; }; + my $cfg = cfg_new $tmpdir, <<EOF; +[publicinbox "a"] + address = a\@example.com + inboxdir = $tmpdir/aa +[publicinbox "b"] + address = b\@example.com + inboxdir = $tmpdir/aa +EOF + $cfg->fill_all; + like $w, qr!`\Q$tmpdir/aa\E' used by both!, 'inboxdir conflict warned'; +} + +{ + my $w = ''; + local $SIG{__WARN__} = sub { $w .= "@_"; }; + my $cfg = cfg_new $tmpdir, <<EOF; +[publicinbox "a"] + address = a\@example.com + inboxdir = $tmpdir/a + newsgroup = inbox.test +[publicinbox "b"] + address = b\@example.com + inboxdir = $tmpdir/b + newsgroup = inbox.tesT +EOF + $cfg->fill_all; + like $w, qr!`inbox\.test' used by both!, 'newsgroup conflict warned'; + like $w, qr!`inbox\.tesT' lowercased!, 'upcase warned'; +} + +done_testing; @@ -1,5 +1,5 @@ #!perl -w -# Copyright (C) 2020-2021 all contributors <meta@public-inbox.org> +# Copyright (C) all contributors <meta@public-inbox.org> # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt> # unit tests (no network) for IMAP, see t/imapd.t for end-to-end tests use strict; @@ -9,12 +9,12 @@ require_git 2.6; require_mods(qw(-imapd)); require_ok 'PublicInbox::IMAP'; require_ok 'PublicInbox::IMAPD'; +use PublicInbox::IO qw(write_file); my ($tmpdir, $for_destroy) = tmpdir(); my $cfgfile = "$tmpdir/config"; { - open my $fh, '>', $cfgfile or BAIL_OUT $!; - print $fh <<EOF or BAIL_OUT $!; + write_file '>', $cfgfile, <<EOF; [publicinbox "a"] inboxdir = $tmpdir/a newsgroup = x.y.z @@ -23,9 +23,8 @@ my $cfgfile = "$tmpdir/config"; newsgroup = x.z.y [publicinbox "c"] inboxdir = $tmpdir/c - newsgroup = IGNORE.THIS + newsgroup = ignore.this.9 EOF - close $fh or BAIL_OUT $!; local $ENV{PI_CONFIG} = $cfgfile; for my $x (qw(a b c)) { ok(run_script(['-init', '-Lbasic', '-V2', $x, "$tmpdir/$x", @@ -37,8 +36,8 @@ EOF local $SIG{__WARN__} = sub { push @w, @_ }; $imapd->refresh_groups; my $self = { imapd => $imapd }; - is(scalar(@w), 1, 'got a warning for upper-case'); - like($w[0], qr/IGNORE\.THIS/, 'warned about upper-case'); + is(scalar(@w), 1, 'got a warning for slice-like name'); + like($w[0], qr/ignore\.this\.9/i, 'warned about slice-like name'); my $res = PublicInbox::IMAP::cmd_list($self, 'tag', 'x', '%'); is(scalar($$res =~ tr/\n/\n/), 2, 'only one result'); like($$res, qr/ x\r\ntag OK/, 'saw expected'); |