Skip to content

Commit

Permalink
fixed Mojo::Date to not crash on invalid dates
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Mar 16, 2009
1 parent 301912a commit 796eb0b
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions Changes
Expand Up @@ -10,6 +10,7 @@ This file documents the revision history for Perl extension Mojo.
routes internals.
- Added Makefile.PL generator.
- Support more CGI implementations.
- Fixed Mojo::Date to not crash on invalid dates. (vti)
- Fixed tokenizer in MojoX::Routes::Pattern to support "0" values.
(Anatoly Sharifulin)
- Fixed parsing of "0" in Mojo::Path. (charsbar)
Expand Down
1 change: 1 addition & 0 deletions lib/Mojo/Date.pm
Expand Up @@ -85,6 +85,7 @@ sub parse {

my $epoch;

# Prevent crash
eval {
$epoch =
Time::Local::timegm($second, $minute, $hour, $day, $month, $year);
Expand Down
2 changes: 1 addition & 1 deletion t/mojo/date.t
Expand Up @@ -30,6 +30,6 @@ is($date->epoch, 0);
is("$date", 'Thu, 01 Jan 1970 00:00:00 GMT');
is($date->parse('Thu, 01 Jan 1970 00:00:00 GMT')->epoch, 0);

# Wrong time checks
# Bad time checks
ok(not defined $date->parse('Mon, 01 Jan 1900 00:00:00'));
is($date->epoch, 0);

0 comments on commit 796eb0b

Please sign in to comment.