kotlinx.serialization icon indicating copy to clipboard operation
kotlinx.serialization copied to clipboard

CBOR tagged data can't be deserialized

Open wkornewald opened this issue 4 years ago • 4 comments

Describe the bug

When you have CBOR data that is tagged, deserialization fails with an exception. With tags I'm referring to section 3.4 of the RFC:

https://datatracker.ietf.org/doc/html/rfc8949#section-3.4

In our case for the CovPass / covid vaccination certificate app some countries use tag 0 to annotate strings as being in date/time format.

The other issue is that we can't decode the COSE data format because the array is tagged with 18:

https://cose-wg.github.io/cose-spec/#rfc.appendix.C.2.1

  1. By default, tags should just be ignored during deserialization.
  2. We could need an annotation that a certain tag should be used for serialization and optionally also be required during deserialization.
  3. For more dynamic tagging something like a special CborTagged(tag, data) object would be nice which allows extracting arbitrary tags (or null) during deserialization and setting arbitrary tags during serialization.

Environment

  • Kotlin version: 1.5.10
  • Library version: 1.2.1

wkornewald avatar Jun 18 '21 06:06 wkornewald

Does #1614 solve this? It ignores tags by default

sandwwraith avatar May 12 '23 16:05 sandwwraith

Not really. We need to be able to work with the tags, i.e. match them or extract them and set them.

wkornewald avatar May 12 '23 19:05 wkornewald

I'll leave this open then

sandwwraith avatar May 15 '23 15:05 sandwwraith

see #2412

JesusMcCloud avatar Aug 18 '23 14:08 JesusMcCloud