Skip to content

Commit

Permalink
handle a few more special cases
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Feb 11, 2015
1 parent 1502135 commit 45226f6
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/Mojo/Date.pm
Expand Up @@ -28,7 +28,7 @@ sub parse {
# RFC 850/1036 (Sunday, 06-Nov-94 08:49:37 GMT)
my $offset = 0;
my ($day, $month, $year, $h, $m, $s);
if ($date =~ /^\w+\,\s*(\d+)\W+(\w+)\D+(\d+)\s+(\d+):(\d+):(\d+)\s+\w+$/) {
if ($date =~ /^\w+\W+(\d+)\W+(\w+)\D+(\d+)\W+(\d+):(\d+):(\d+)\W*\w+$/) {
($day, $month, $year, $h, $m, $s) = ($1, $MONTHS{$2}, $3, $4, $5, $6);
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Mojo/Util.pm
Expand Up @@ -49,7 +49,7 @@ my %XML = (
);

# "Sun, 06 Nov 1994 08:49:37 GMT" and "Sunday, 06-Nov-94 08:49:37 GMT"
my $EXPIRES_RE = qr/(\w+\,\s*\d+\W+\w+\D+\d+\s+\d+:\d+:\d+\s+\w+)/;
my $EXPIRES_RE = qr/(\w+\W+\d+\W+\w+\D+\d+\W+\d+:\d+:\d+\W*\w+)/;

# Encoding cache
my %CACHE;
Expand Down
2 changes: 2 additions & 0 deletions t/mojo/date.t
Expand Up @@ -44,6 +44,8 @@ is(Mojo::Date->new('Sun, 06-Nov-1994 08:49:37 UTC')->epoch,
784111777, 'right epoch value');
is(Mojo::Date->new('Sunday,06 Nov 94 08:49:37 UTC')->epoch,
784111777, 'right epoch value');
is(Mojo::Date->new('Sunday 06 Nov 94 08:49:37UTC')->epoch,
784111777, 'right epoch value');
is(Mojo::Date->new('2014-08-20 20:45:00')->epoch,
1408567500, 'right epoch value');

Expand Down
4 changes: 4 additions & 0 deletions t/mojo/util.t
Expand Up @@ -102,6 +102,10 @@ is_deeply split_cookie_header(
'a=b; expires=Sun,06 Nov 1994 08:49:37 UTC; path=/'),
[['a', 'b', 'expires', 'Sun,06 Nov 1994 08:49:37 UTC', 'path', '/']],
'right result';
is_deeply split_cookie_header(
'a=b; expires=Sunday 06 Nov 94 08:49:37UTC; path=/'),
[['a', 'b', 'expires', 'Sunday 06 Nov 94 08:49:37UTC', 'path', '/']],
'right result';

# unindent
is unindent(" test\n 123\n 456\n"), "test\n 123\n456\n",
Expand Down

0 comments on commit 45226f6

Please sign in to comment.