mirror of
https://github.com/araddon/dateparse.git
synced 2024-11-10 11:51:54 +08:00
Dont allow unix-seconds to be negative
This commit is contained in:
parent
6da1fef9ab
commit
ca7e753bd1
@ -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() {
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user