Skip to content
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

Add support for CBOR encoding #2

Closed
wants to merge 4 commits into from

Conversation

cmitsakis
Copy link

@cmitsakis cmitsakis commented May 25, 2022

I needed support for CBOR encoding, so I created this.

It is enabled only if you use the --encoding-cbor flag.
Ideally it shouldn't need a flag. I should detect if the value is valid CBOR, but the function cbor.Valid() from https://github.com/fxamacker/cbor recognizes as CBOR values that are not CBOR.

I can make changes if you want.

@x448
Copy link

x448 commented Sep 20, 2022

@cmitsakis The cbor.Valid() in v2.4.0 ignores extraneous data after the valid CBOR data in order to be consistent with Decoder which can continue validating and decoding extra data.

Next release of fxamacker/cbor will add an option to treat the extraneous data differently in Valid().

Source:

Comment by @fxamacker at fxamacker/cbor,

Unmarshal() and Valid() work this way to be consistent with decoder, which can continue decoding extra data. But I understand your point because Unmarshal() and Valid() only decodes one piece of data.

Rejecting extraneous data would be a breaking change. So maybe it can be added as a non-default DecOption. This new option would only apply to Unmarshal() and Valid().

@x448
Copy link

x448 commented Jan 1, 2023

@cmitsakis fxamacker/cbor#380 fixed the issue you mentioned about Valid() after classifying it as a bug:

After rereading relevant sections in RFC 8949 and comparing to how this is handled in encoding/json, I changed this from enhancement to a bug.

@boreq
Copy link
Owner

boreq commented Sep 18, 2024

As they say "the mills of free software grind slowly". I created a new pull request #6 to make everything more robust, avoid config flags, make adding more formats easy etc. Let me know if it works for you or not, I rarely work with CBOR so its possible I missed something.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants