Allow decoding RFC 3339 CBOR strings to time.Time.

We had been relying on a bug in the library when it should have been rejected by default. That bug
has been fixed and a new option added to opt-in to the behavior we need.
This commit is contained in:
Ben Luddy 2024-05-09 14:37:06 -04:00
parent c4279660ca
commit b24defacc5
No known key found for this signature in database
GPG Key ID: A6551E73A5974C30

View File

@ -84,6 +84,10 @@ var Decode cbor.DecMode = func() cbor.DecMode {
// When decoding an unrecognized tag to interface{}, return the decoded tag content
// instead of the default, a cbor.Tag representing a (number, content) pair.
UnrecognizedTagToAny: cbor.UnrecognizedTagContentToAny,
// For parity with JSON, strings can be decoded into time.Time if they are RFC 3339
// timestamps.
ByteStringToTime: cbor.ByteStringToTimeAllowed,
}.DecMode()
if err != nil {
panic(err)