+use PublicInbox::IMAPD;
+use PublicInbox::TestCommon;
+require_mods(qw(DBD::SQLite));
+require_git 2.6;
+use POSIX qw(strftime);
+
+{
+ my $parse_date = \&PublicInbox::IMAP::parse_date;
+ is(strftime('%Y-%m-%d', gmtime($parse_date->('02-Oct-1993'))),
+ '1993-10-02', 'parse_date works');
+ is(strftime('%Y-%m-%d', gmtime($parse_date->('2-Oct-1993'))),
+ '1993-10-02', 'parse_date works w/o leading zero');
+
+ is($parse_date->('2-10-1993'), undef, 'bad month');
+
+ # from what I can tell, RFC 3501 says nothing about date-month
+ # case-insensitivity, so be case-sensitive for now
+ is($parse_date->('02-oct-1993'), undef, 'case-sensitive month');
+}
+
+my ($tmpdir, $for_destroy) = tmpdir();
+my $cfgfile = "$tmpdir/config";
+{
+ open my $fh, '>', $cfgfile or BAIL_OUT $!;
+ print $fh <<EOF or BAIL_OUT $!;
+[publicinbox "a"]
+ inboxdir = $tmpdir/a
+ newsgroup = x.y.z
+[publicinbox "b"]
+ inboxdir = $tmpdir/b
+ newsgroup = x.z.y
+[publicinbox "c"]
+ inboxdir = $tmpdir/c
+ newsgroup = IGNORE.THIS
+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",
+ "https://example.com/$x", "$x\@example.com"]),
+ "init $x");
+ }
+ my $imapd = PublicInbox::IMAPD->new;
+ my @w;
+ 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');
+ 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');
+ $res = PublicInbox::IMAP::cmd_list($self, 'tag', 'x.', '%');
+ is(scalar($$res =~ tr/\n/\n/), 3, 'only one result');
+ is(scalar(my @x = ($$res =~ m/ x\.[zy]\r\n/g)), 2, 'match expected');
+
+ $res = PublicInbox::IMAP::cmd_list($self, 't', 'x.(?{die "RCE"})', '%');
+ like($$res, qr/\At OK /, 'refname does not match attempted RCE');
+ $res = PublicInbox::IMAP::cmd_list($self, 't', '', '(?{die "RCE"})%');
+ like($$res, qr/\At OK /, 'wildcard does not match attempted RCE');
+}
+