Subject: | Fails on hosts where hostname contains a dash |
Filenames contain the hostname, but the regexp in get_messages does not allow the filenames
to contain a dash. The fix is simply to add a dash ( - ), into the regexp in line 565.
@messages=map{ /^(\d[\w.:,_\-]+)$/ && -f "$path/$1"?$1:() } readdir(DIR);
I attached a test case which demonstrates the bug and the fix.
I've been able to work around the issue by monkey-patching Maildir::Lite's hostname() (see
attached workaround.pm) but I have to force the cpan install since the test cases fail.
Many thanks!
Subject: | 03-hostname-dash.t |
#!/usr/bin/perl
##!perl -T
use warnings;
use strict;
use Test::More tests => 1;
use Test::Files;
use Maildir::Lite;
BEGIN {
# temporarily disable warnings for redefine while we monkey-patch Maildir::Lite
no warnings 'redefine';
# Maildir::Lite has a bug where it does not properly handle hostnames with dashes
*Maildir::Lite::hostname = sub { return "app-01" };
use warnings 'redefine';
}
my $dir_name="/tmp/.maildir_lit_t_$$/";
my $rc;
my $test_message="This is a basic test message $$";
my $mdir=Maildir::Lite->new(dir=>$dir_name);
$rc=$mdir->mkdir("basic");
$rc=$mdir->creat_message($test_message);
my ($fh,$stat)=$mdir->get_next_message("new");
ok($stat==0, "Get next message from new directory");
Subject: | Maildir-Lite.diff |
--- lib/Maildir/Lite.pm.orig 2010-11-27 15:21:08.000000000 -0800
+++ lib/Maildir/Lite.pm 2010-11-27 15:21:22.000000000 -0800
@@ -562,7 +562,7 @@
return -1;
}
- @messages=map{ /^(\d[\w.:,_]+)$/ && -f "$path/$1"?$1:() } readdir(DIR);
+ @messages=map{ /^(\d[\w.:,_\-]+)$/ && -f "$path/$1"?$1:() } readdir(DIR);
closedir(DIR);
Subject: | workaround.pm |
package Foo;
use Maildir::Lite;
BEGIN {
# temporarily disable warnings for redefine while we monkey-patch Maildir::Lite
no warnings 'redefine';
# Maildir::Lite has a bug where it does not properly handle hostnames with dashes
*Maildir::Lite::hostname = sub { my $hostname = Sys::Hostname::hostname(); $hostname =~ s|\-||g; return $hostname };
use warnings 'redefine';
}