Subject: [Cbor] Validity checking

From: Laurence Lundblade <[email-masked]>
Date: Tue, 19 Nov 2019 21:11:42 +0800

I’m not sure if this should be filed as an issue or not, so I’ll put it in email first.

Here’s three classes of validity checks:

1) Easy
- Check whether the type of a tagged item is right, for example that tagged content of a tag 0 (string date) is a string
Checks in the class are easy and take no extra resources except a few lines of code. Any decoder author
Is likely to implement this check for tagged types they support because it is sort of the obvious thing to do.

2) Medium
- Check for duplicate keys in a map
Check in this class require writing a some special code and may use a lot of extra resources, particularly memory

3) Should not be done by a generic decoder (IMO)
- Check MIME structure
- Check unicode characters
- Check for valid base64
- Check for valid date string
It would be costly and inconvenient to do these in a generic CBOR decoder, but not at all for a MIME decoder, unicode renderer or base 64 decoder, so it makes almost no sense for a generic CBOR decoder to implement them. It would be waste of time and resources.

I don’t think it useful to talk of validity checking or not validity checking generic decoders as in the latest section 5.4. (IMO) only an insane decoder would check all validity as it would one that includes a MIME parser, base64 decoder and such. Many generic decoders will do no validity checking at all and be perfectly OK because they don’t decode tagged types and don’t do duplicate checking.

LL