Small bugfixes, defensive checks, and improvements#753
Merged
Conversation
This issue doesn't affect CBOR encoding or decoding. Previously, the diagnostic functions which are used to translate CBOR into Extended Diagnostic Notation (human readable text for debugging) were rejecting valid U+FFFD character. This commit fixes Diagnose() and DiagnoseFirst() to no longer reject valid U+FFFD character.
This refactor does not change actual behavior of the CBOR codec, but it improves conformance to Go's sort.Interface. This commit does not change behavior because: - sort is used to deduplicate struct fields and fields with identical index are deduplicated - sort is used to order struct fields after deduplication and we don't expect identical fields after deduplication - sort is used to order map keys for encoding and we don't expect identical Go map keys
This commit adds a bounds check when decoding floating-point epoch time, because extreme values (hundreds of billions of years) can exceed the range of int64(seconds) if it was encoded using a different library.
This commit always returns a copy of cborNil slice when RawMessage is empty. Previously, RawMessage.MarshalCBOR() returned an internal cborNil slice when RawMessage is empty. This did not prevent the possibility of external callers accidentally mutating the internal cborNil slice. This issue only affects external direct call of RawMessage.MarshalCBOR. The Marhsal() and Encode() functions already return a copy of data, so they were not affected by this issue.
6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR fixes 4 minor issues found during refactoring:
NOTE: It is generally good practice to avoid using floating point to store epoch time for obvious reasons (even when not using CBOR).