about summary refs log tree commit homepage
path: root/lib/PublicInbox/WatchMaildir.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2016-06-24 20:37:52 +0000
committerEric Wong <e@80x24.org>2016-06-24 20:37:52 +0000
commit6e87b61cbf5fdcbed22bf3dd8103949caf22dd59 (patch)
tree3350797a0cf88c7c326445448c14151ebbc4bdee /lib/PublicInbox/WatchMaildir.pm
parent40782735e74e427997b5b900d60cc07597e330c3 (diff)
downloadpublic-inbox-6e87b61cbf5fdcbed22bf3dd8103949caf22dd59.tar.gz
Trashed messages and drafts are probably not intended for
importing, so do not import them.  Dovecot uses extra flags via
lowercase letters, so we must support those (as that's the
server I use).
Diffstat (limited to 'lib/PublicInbox/WatchMaildir.pm')
-rw-r--r--lib/PublicInbox/WatchMaildir.pm11
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/PublicInbox/WatchMaildir.pm b/lib/PublicInbox/WatchMaildir.pm
index 72bd3d08..b25704e6 100644
--- a/lib/PublicInbox/WatchMaildir.pm
+++ b/lib/PublicInbox/WatchMaildir.pm
@@ -1,5 +1,8 @@
 # Copyright (C) 2016 all contributors <meta@public-inbox.org>
 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
+#
+# ref: https://cr.yp.to/proto/maildir.html
+#        http://wiki2.dovecot.org/MailboxFormat/Maildir
 package PublicInbox::WatchMaildir;
 use strict;
 use warnings;
@@ -89,7 +92,7 @@ sub _try_fsn_paths {
 
 sub _remove_spam {
         my ($self, $path) = @_;
-        $path =~ /:2,[A-R]*S[T-Z]*\z/ or return;
+        $path =~ /:2,[A-R]*S[T-Z]*\z/i or return;
         my $mime = _path_to_mime($path) or return;
         _force_mid($mime);
         foreach my $inbox (values %{$self->{mdmap}}) {
@@ -127,7 +130,11 @@ sub _force_mid {
 sub _try_path {
         my ($self, $path) = @_;
         my @p = split(m!/+!, $path);
-        return unless $p[-1] =~ /\A[a-zA-Z0-9][\w:,=\.]+\z/;
+        return if $p[-1] !~ /\A[a-zA-Z0-9][\w:,=\.]+\z/;
+        if ($p[-1] =~ /:2,([A-Z]+)\z/i) {
+                my $flags = $1;
+                return if $flags =~ /[DT]/; # no [D]rafts or [T]rashed mail
+        }
         return unless -f $path;
         if ($path !~ $self->{mdre}) {
                 warn "unrecognized path: $path\n";