decode: fix maximum time offset values (#706)

According to RFC3339 section 5.6, the maximum time offset values for
hours and minutes is 23 and 59, respectively.
This commit is contained in:
Cameron Moore
2021-12-22 03:29:52 -06:00
committed by GitHub
parent 696dd25c17
commit 5cbdea6192
2 changed files with 4 additions and 4 deletions
+2 -2
View File
@@ -117,7 +117,7 @@ func parseDateTime(b []byte) (time.Time, error) {
if err != nil {
return time.Time{}, err
}
if hours > 24 {
if hours > 23 {
return time.Time{}, newDecodeError(b[:1], "invalid timezone offset hours")
}
@@ -125,7 +125,7 @@ func parseDateTime(b []byte) (time.Time, error) {
if err != nil {
return time.Time{}, err
}
if minutes > 60 {
if minutes > 59 {
return time.Time{}, newDecodeError(b[:1], "invalid timezone offset minutes")
}
+2 -2
View File
@@ -2683,11 +2683,11 @@ world'`,
},
{
desc: `invalid zone offset hours`,
data: `a=0000-01-01 00:00:00+25:00`,
data: `a=0000-01-01 00:00:00+24:00`,
},
{
desc: `invalid zone offset minutes`,
data: `a=0000-01-01 00:00:00+00:61`,
data: `a=0000-01-01 00:00:00+00:60`,
},
{
desc: `invalid character in zone offset hours`,