mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-06-11 01:25:53 -04:00
Merge pull request #2087 from lightpanda-io/invalid_datetime
protect against index out of bound on invalid datetime
This commit is contained in:
@@ -335,7 +335,7 @@ pub const DateTime = struct {
|
||||
}
|
||||
const tm = try parser.time(false);
|
||||
|
||||
if (parser.consumeIf(' ') == false) {
|
||||
if (parser.unconsumed() == 0 or parser.consumeIf(' ') == false) {
|
||||
return error.InvalidTime;
|
||||
}
|
||||
|
||||
@@ -1496,6 +1496,9 @@ test "DateTime: parse RFC822" {
|
||||
try testing.expectError(error.InvalidTime, DateTime.parse("Wed, 01 Jan 20 20:1a:22 X", .rfc822));
|
||||
try testing.expectError(error.InvalidTime, DateTime.parse("Wed, 01 Jan 20 20:1a:22 ZZ", .rfc822));
|
||||
|
||||
// Missing timezone - input ends exactly at time boundary (was causing index out of bounds)
|
||||
try testing.expectError(error.InvalidTime, DateTime.parse("Wed, 01 Jan 2020 10:10:10", .rfc822));
|
||||
|
||||
{
|
||||
const dt = try DateTime.parse("31 Dec 68 23:59 Z", .rfc822);
|
||||
try testing.expectEqual(3124223940000000, dt.micros);
|
||||
|
||||
Reference in New Issue
Block a user