diff options
author | Eric Wong <e@80x24.org> | 2021-09-15 17:43:41 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2021-09-15 18:09:09 +0000 |
commit | ae6cd61cf7cb9988d6e9178dbdeebfb6109e74da (patch) | |
tree | 2e59bb288d586c1d42771e5cd2f9233ff4620c8a /lib/PublicInbox/LeiSavedSearch.pm | |
parent | 375b3ccfd3ca978281cb3869b62fc91eebc60d6e (diff) | |
download | public-inbox-ae6cd61cf7cb9988d6e9178dbdeebfb6109e74da.tar.gz |
We failed to account for IMAP mailboxes containing `/' characters when creating saved search files for them. Reported-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org> Link: https://public-inbox.org/meta/20210915123347.knr4qpaei73tjc5q@meerkat.local/
Diffstat (limited to 'lib/PublicInbox/LeiSavedSearch.pm')
-rw-r--r-- | lib/PublicInbox/LeiSavedSearch.pm | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/PublicInbox/LeiSavedSearch.pm b/lib/PublicInbox/LeiSavedSearch.pm index 8ceaaf01..96ff816e 100644 --- a/lib/PublicInbox/LeiSavedSearch.pm +++ b/lib/PublicInbox/LeiSavedSearch.pm @@ -39,21 +39,21 @@ sub cfg_dump ($$) { sub lss_dir_for ($$;$) { my ($lei, $dstref, $on_fs) = @_; - my @n; + my $pfx; if ($$dstref =~ m,\Aimaps?://,i) { # already canonicalized require PublicInbox::URIimap; my $uri = PublicInbox::URIimap->new($$dstref)->canonical; $$dstref = $$uri; - @n = ($uri->mailbox); + $pfx = $uri->mailbox; } else { # can't use Cwd::abs_path since dirname($$dstref) may not exist $$dstref = $lei->rel2abs($$dstref); $$dstref =~ tr!/!/!s; - @n = ($$dstref =~ m{([^/]+)/*\z}); # basename + $pfx = $$dstref; } - push @n, sha256_hex($$dstref); + ($pfx) = ($pfx =~ m{([^/]+)/*\z}); # basename my $lss_dir = $lei->share_path . '/saved-searches/'; - my $d = $lss_dir . join('-', @n); + my $d = "$lss_dir$pfx-".sha256_hex($$dstref); # fall-back to looking up by st_ino + st_dev in case we're in # a symlinked or bind-mounted path @@ -61,7 +61,7 @@ sub lss_dir_for ($$;$) { my @cur = stat(_); my $want = pack('dd', @cur[1,0]); # st_ino + st_dev my ($c, $o, @st); - for my $g ("$n[0]-*", '*') { + for my $g ("$pfx-*", '*') { my @maybe = glob("$lss_dir$g/lei.saved-search"); for my $f (@maybe) { $c = cfg_dump($lei, $f) // next; |