Make the Date macro handle leading and trailing whitespace. Fixes bug #11542.

This commit is contained in:
Colin Kuskie 2010-05-02 01:07:35 -07:00
parent 42a6b612f7
commit b9c2a3b0ad
3 changed files with 15 additions and 6 deletions

View file

@ -12,6 +12,7 @@
- added: CHI cache driver
- added #11498: Gallery: Automatically adjust orientation of images based on EXIF data
- fixed #11547: Default Inbox View Template Delete buttton failure
- fixed #11542: Date macro can pass in epoch values that do not pass regex checks
7.9.3
- added #11477: No synopsis in asset now means no synopsis in search index

View file

@ -42,6 +42,10 @@ sub process {
if (! defined $time) {
$time = time();
}
else {
$time =~ s/^\s+//;
$time =~ s/\s+$//;
}
my $temp = $session->datetime->epochToHuman($time, $_[0]);
return $temp;
}

View file

@ -8,7 +8,6 @@
# http://www.plainblack.com info@plainblack.com
#-------------------------------------------------------------------
# ---- BEGIN DO NOT EDIT ----
use FindBin;
use strict;
use lib "$FindBin::Bin/../lib";
@ -17,9 +16,9 @@ use WebGUI::Test;
use WebGUI::Session;
use WebGUI::Macro::D_date;
use Data::Dumper;
# ---- END DO NOT EDIT ----
use Test::More; # increment this value for each test you create
use Test::More;
use Test::Exception;
my $wgbday = WebGUI::Test->webguiBirthday;
@ -34,7 +33,7 @@ my @testSets = (
},
);
my $numTests = scalar @testSets + 2;
my $numTests = scalar @testSets + 4;
plan tests => $numTests;
@ -62,5 +61,10 @@ is($output, $session->datetime->epochToHuman($time1), 'checking default time and
##Checking for edge case, time=0
is WebGUI::Macro::D_date::process($session, '', 0),
'12/31/1969 6:00 pm',
'...checking for handling time=0';
'12/31/1969 6:00 pm',
'...checking for handling time=0';
lives_ok { WebGUI::Macro::D_date::process($session, '', ' 0') }
'handles leading whitespace okay';
lives_ok { WebGUI::Macro::D_date::process($session, '', '0 ') }
'handles trailing whitespace okay';