-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CBOR parser doesn't skip tags #1968
Comments
Can you provide the error message? |
It's this one here: |
I‘v read the CBOR standard document and its implementation in the source code, it does not support data of major-type 6(Optional Tagging of Items). One of the reasons is that the other major-type data has satisfy various data types of JSON.
so can we add a case to skip it to avoid parsing error? @nlohmann |
The documentation states that the library does not support tags at this point, so I would not speak of a bug. I am hesitant of skipping tags, because this would, to my understanding, silently change the type or intention of the encoding. Or, to put it differently, how would you propose mapping such read bytes to JSON values? |
This comment has been minimized.
This comment has been minimized.
Just ignore them. This is perfectly acceptable according to the standard:
|
This comment has been minimized.
This comment has been minimized.
It's a bit odd that you have a bot to close issues that nobody replies to after 1 month. I don't think it's going to magically fix itself! |
This is a one-man-show, and I do not want to be overwhelmed by inactive issues. Since I will never be able to work on all of them, I'd rather keep the active ones open. |
This comment has been minimized.
This comment has been minimized.
Tags should be skipped to allow roundtripping after #2244 is merged. |
Alright, I finally had time to work on this. My idea would be to pass the
Also possible (but more difficult to implement would be):
Any comments on this? |
Sounds sensible to me. |
Using 456478b (3.7.3)
The following code should parse a CBOR value:
The value I'm parsing (
0xd9d9f7
) is simply the optimal "magic number" tag for CBOR documents. From the specification:Byte 0xd9 should be fine because it is equal to
(6 << 5) | 25
, in other words it has a major type of 6 (a tag), and lower 5 bits of 25, which for a tag means the actual tag value follows in auint16
, so it should just skip the following 2 bytes.Some extra code needs to be added here. It doesn't understand tags at all.
The text was updated successfully, but these errors were encountered: