Dont allow unix-seconds to be negative

This commit is contained in:
Aaron Raddon 2017-10-07 09:34:59 -07:00
parent 6da1fef9ab
commit ca7e753bd1
2 changed files with 9 additions and 1 deletions

View File

@ -574,7 +574,12 @@ iterRunes:
}
if t.IsZero() {
if secs, err := strconv.ParseInt(datestr, 10, 64); err == nil {
t = time.Unix(secs, 0)
if secs < 0 {
// Now, for unix-seconds we aren't going to guess a lot
// nothing before unix-epoch
} else {
t = time.Unix(secs, 0)
}
}
}
if !t.IsZero() {

View File

@ -468,6 +468,9 @@ func TestParse(t *testing.T) {
_, err = ParseAny("138421636711122233311111") // too many digits
assert.NotEqual(t, nil, err)
_, err = ParseAny("-1314")
assert.NotEqual(t, nil, err)
}
func testDidPanic(datestr string) (paniced bool) {