Fixed by attached patch.
--
Paul Evans
=== modified file 'lib/Algorithm/Cron.pm'
--- lib/Algorithm/Cron.pm 2013-11-06 18:09:05 +0000
+++ lib/Algorithm/Cron.pm 2014-05-14 16:25:26 +0000
@@ -1,7 +1,7 @@
# You may distribute under the terms of either the GNU General Public License
# or the Artistic License (the same terms as Perl itself)
#
-# (C) Paul Evans, 2012 -- leonerd@leonerd.org.uk
+# (C) Paul Evans, 2012-2014 -- leonerd@leonerd.org.uk
package Algorithm::Cron;
@@ -251,6 +251,8 @@
if( exists $params{crontab} ) {
my $crontab = delete $params{crontab};
+ s/^\s+//, s/\s+$// for $crontab;
+
my @fields = split m/\s+/, $crontab;
@fields >= 5 or croak "Expected at least 5 crontab fields";
@fields <= 6 or croak "Expected no more than 6 crontab fields";
=== modified file 't/02cron.t'
--- t/02cron.t 2013-04-06 19:14:15 +0000
+++ t/02cron.t 2014-05-14 16:25:26 +0000
@@ -82,4 +82,19 @@
dies_ok { Algorithm::Cron->new( crontab => 'one * * * *', base => 'utc' ) }
'Unrecognised number dies';
+# RT95454
+{
+ my $cron = Algorithm::Cron->new(
+ base => 'utc',
+ crontab => ' 20 23 1 1 *'
+ );
+
+ is_deeply( [ $cron->min ], [ 20 ], '$cron->min for leading space' );
+ is_deeply( [ $cron->sec ], [ 0 ], '$cron->sec for leading space' );
+
+ my $next = $cron->next_time( 0 );
+
+ is( $next, 84000, '->next_time for crontab with space' );
+}
+
done_testing;