about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2021-09-14 19:35:28 +0000
committerEric Wong <e@80x24.org>2021-09-14 20:12:33 +0000
commit076f1322ba8fd0386760fc68a9df9efd34afe4a6 (patch)
tree8ba0029659d9aa6edcaa94fef361285b879bd109
parentdacde5e35071579fb25c3f5276355ec76c840151 (diff)
downloadpublic-inbox-076f1322ba8fd0386760fc68a9df9efd34afe4a6.tar.gz
Untested at the moment(*), but we were inadvertantly truncating
mailbox names with '/' due to our work-in-progress handling of
"/;UID=$NUM" parameter.

(*) strangely, my dovecot instance doesn't allow '/' by default,
    so the change to xt/net_writer-imap.t is untested.

Reported-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
Link: https://public-inbox.org/meta/20210914175025.eq7s2shkc323itaf@meerkat.local/
-rw-r--r--lib/PublicInbox/URIimap.pm2
-rw-r--r--t/uri_imap.t2
-rw-r--r--xt/net_writer-imap.t3
3 files changed, 5 insertions, 2 deletions
diff --git a/lib/PublicInbox/URIimap.pm b/lib/PublicInbox/URIimap.pm
index a309fde0..6907e32a 100644
--- a/lib/PublicInbox/URIimap.pm
+++ b/lib/PublicInbox/URIimap.pm
@@ -63,7 +63,7 @@ sub path {
         my ($self) = @_;
         my (undef, undef, $path) = uri_split($$self);
         $path =~ s!\A/+!!;
-        $path =~ s![/;].*\z!!; # [;UIDVALIDITY=nz-number]/;UID=nz-number
+        $path =~ s!/?;.*\z!!; # [;UIDVALIDITY=nz-number]/;UID=nz-number
         $path eq '' ? undef : $path;
 }
 
diff --git a/t/uri_imap.t b/t/uri_imap.t
index 14f0f346..b9e4583d 100644
--- a/t/uri_imap.t
+++ b/t/uri_imap.t
@@ -130,5 +130,7 @@ $uri = PublicInbox::URIimap->new('imap://[::1]:36281/');
 my $cred = bless { username => $uri->user, password => $uri->password };
 is($cred->{username}, undef, 'user is undef in array context');
 is($cred->{password}, undef, 'password is undef in array context');
+$uri = PublicInbox::URIimap->new('imap://u@example.com/slash/separator');
+is($uri->mailbox, 'slash/separator', "`/' separator accepted");
 
 done_testing;
diff --git a/xt/net_writer-imap.t b/xt/net_writer-imap.t
index 0a4cea68..f1228090 100644
--- a/xt/net_writer-imap.t
+++ b/xt/net_writer-imap.t
@@ -19,7 +19,8 @@ require_mods('Mail::IMAPClient');
 require_ok 'PublicInbox::NetWriter';
 my $host = (split(/\./, hostname))[0];
 my ($base) = ($0 =~ m!\b([^/]+)\.[^\.]+\z!);
-my $folder = "INBOX.$base-$host-".strftime('%Y%m%d%H%M%S', gmtime(time)).
+my $SEP = $ENV{IMAP_SEPARATOR} || '.';
+my $folder = "INBOX$SEP$base-$host-".strftime('%Y%m%d%H%M%S', gmtime(time)).
                 "-$$-".sprintf('%x', int(rand(0xffffffff)));
 my $nwr = PublicInbox::NetWriter->new;
 chop($imap_url) if substr($imap_url, -1) eq '/';