From 3990899d7eec45790be0f4a5344e387a89098181 Mon Sep 17 00:00:00 2001 From: Thomas Pelletier Date: Tue, 30 Nov 2021 20:22:11 -0500 Subject: [PATCH] Decoder: check tz has : between hours and minutes (#691) Fixes #690 --- decode.go | 4 ++++ unmarshaler_test.go | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/decode.go b/decode.go index 4b0c509..c88cbad 100644 --- a/decode.go +++ b/decode.go @@ -109,6 +109,10 @@ func parseDateTime(b []byte) (time.Time, error) { return time.Time{}, newDecodeError(b[:1], "invalid timezone offset character") } + if b[3] != ':' { + return time.Time{}, newDecodeError(b[3:4], "expected a : separator") + } + hours := digitsToInt(b[1:3]) minutes := digitsToInt(b[4:6]) seconds := direction * (hours*3600 + minutes*60) diff --git a/unmarshaler_test.go b/unmarshaler_test.go index 9769917..e771dec 100644 --- a/unmarshaler_test.go +++ b/unmarshaler_test.go @@ -2632,6 +2632,10 @@ world'`, desc: `invalid number of seconds digits with trailing digit`, data: `a=0000-01-01 00:00:000000Z3`, }, + { + desc: `invalid number of seconds`, + data: `a=0000-01-01 00:00:00+27000`, + }, { desc: `carriage return inside basic key`, data: "\"\r\"=42",