Closed benluddy closed 6 months ago
@fxamacker PTAL. I wanted to get a proposed solution up before the end of the week in order to avoid delaying the next release. I'm happy to resolve this in a different way if you prefer.
In addition to current built-in tags, I wonder if we should special case more tags defined in RFC 8949 section 3.4 table 5, specifically CBOR tags 24, 32, 33, 34, and 36.
It is very likely that codec will have built-in support for more tags defined in RFC 8949. It would be safer to disable settings that might create tag validity issues for those tags.
Thoughts?
It's a good question. I'm wary by default about maintaining more special cases than necessary. The behavior of the default options hasn't changed, so at least existing programs that are processing those tags using Tag
will continue to work. Special-casing the tags that are built-in and always validated strikes me as necessary because it prevents the library from marshaling data that it can't itself unmarshal. For other tags, my preference would be to help users migrate to an option that uses RawTag
as the dynamic type of interface{}
values when decoding unrecognized tags to guarantee that roundtripping won't introduce any new tag validity errors for unrecognized tags, and to add warnings about this to, or even deprecate, Tag
. In fact, I will add additional documentation to Tag
as part of this change to mention that options can affect how marshaling and unmarshaling of its content field.
Eventually (v3 wish list?), I think it would be great to arrive at a place like:
Closes #545
Encode options, especially those that control the mapping from Go type to CBOR type, can result in output containing tag validity errors. For tag numbers that are built in, it's possible to "do the right thing" and override those options on a case-by-case basis. This can't and does not prevent tag validity errors for unrecognized tag numbers.
Description
PR Was Proposed and Welcomed in Currently Open Issue
Checklist (for code PR only, ignore for docs PR)
Last line of each commit message should be in this format:
Signed-off-by: Firstname Lastname firstname.lastname@example.com
Certify the Developer's Certificate of Origin 1.1