Subject: | PATCH: Accept colons in maildir messages "unique name" part |
Date: | Sun, 20 Jun 2010 08:17:02 +0200 |
To: | bug-Mail-Box [...] rt.cpan.org |
From: | Stefan Kangas <skangas [...] skangas.se> |
The attached patch makes Mail::Box::Maildir::Message accept colons in
maildir messages "unique name" part of the filename. The patch is
against Mail-Box-2.094.
Some background:
In his write-up "Using maildir format", Dan Bernstein states that a
unique name can be "anything that doesn't contain a colon". However, in
the wild I encountered maildirs where this convention was not respected.
Upon further research I learned that some MDA's apparently use extra
comma delimited fields to hold various pieces of information.
I found one description of this practice at the Dovecot wiki (see
section "Maildir filename extensions"):
http://wiki.dovecot.org/MailboxFormat/Maildir
Mail::Box::Maildir::Message currently relies on the assumption that the
unique name contains no colons. If there are any colons, we get errors:
Use of uninitialized value $set in string ne
at /home/skangas/src/Mail-Box-2.094/lib/Mail/Box/Maildir/Message.pm line 97.
Use of uninitialized value $oldname in concatenation (.) or string
at /home/skangas/src/Mail-Box-2.094/lib/Mail/Box/Maildir/Message.pm line 102.
ERROR: Cannot rename Maildir/test/cur/1256749700.xxxxx.412.9118310093:2:2,
to /cur/:2,: No such file or directory
There may be good reasons for not accepting colons. I don't know of any
such reasons, so in order to get my work done I decided to make this
small change.
Perhaps you will agree.
Thanks,
Stefan Kangas
--- Mail-Box-2.094/lib/Mail/Box/Maildir/Message.pm 2010-04-06 11:17:24.000000000 +0200
+++ Mail-Box-2.094p1/lib/Mail/Box/Maildir/Message.pm 2010-06-20 06:42:33.000000000 +0200
@@ -82,7 +82,7 @@
my $old = $self->filename;
my ($folderdir, $set, $oldname)
- = $old =~ m!(.*)/(new|cur|tmp)/([^:]*)(\:[^:]*)?$!;
+ = $old =~ m!(.*)/(new|cur|tmp)/(.+?)(\:2,[^:]*)?$!;
my $newflags # alphabeticly ordered!
= ($labels->{draft} ? 'D' : '')