Skip to content

Commit

Permalink
Fixing when cookie expiration date received by .NET exceeds max DateTime
Browse files Browse the repository at this point in the history
When receiving a cookie via the JSON wire protocol, the expiration date is
represented as the number of seconds after 12:00:00 AM January 1, 1970
GMT. When a number greater than or equal 253402300800, this is larger than
the maximum value of .NET's DateTime value. This change catches the
ArgumentOutOfRangeException and forcibly sets the expiration to
DateTime.MaxValue (12:59:59 PM December 31, 9999 GMT). Fixes issue SeleniumHQ#5692.
  • Loading branch information
jimevans committed Jan 28, 2014
1 parent 91ee467 commit ebb1a33
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion dotnet/src/webdriver/Remote/RemoteCookieJar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,14 @@ private ReadOnlyCollection<Cookie> GetAllCookies()
long seconds = 0;
if (long.TryParse(cookie["expiry"].ToString(), out seconds))
{
expires = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddSeconds(seconds).ToLocalTime();
try
{
expires = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddSeconds(seconds).ToLocalTime();
}
catch (ArgumentOutOfRangeException)
{
expires = DateTime.MaxValue.ToLocalTime();
}
}
}

Expand Down

0 comments on commit ebb1a33

Please sign in to comment.