Skip to content

Refactor indefinite-length encoding and improve chunk validation during encoding#767

Merged
fxamacker merged 2 commits intomasterfrom
fxamacker/refactor-indefinite-length-encoding
Apr 27, 2026
Merged

Refactor indefinite-length encoding and improve chunk validation during encoding#767
fxamacker merged 2 commits intomasterfrom
fxamacker/refactor-indefinite-length-encoding

Conversation

@fxamacker
Copy link
Copy Markdown
Owner

This PR refactors indefinite-length encoding and improves chuck validation during encoding.

Previously, the encoder rejected invalid chunks in indefinite-length strings based on the Go type. This could mistakenly reject objects that don't match the expected Go type, even if they encode valid chunk data (e.g., with a user-defined CBORMarshaler), and vice versa.

This PR validates a chunk by inspecting the encoded chunk's CBOR type to ensure that the encoded chunk data is definite-length items of the same major type as the parent.

@fxamacker fxamacker added bugfix improvement improvement that does not add new feature labels Apr 26, 2026
@fxamacker fxamacker force-pushed the fxamacker/refactor-indefinite-length-encoding branch from 4937e43 to 1b36774 Compare April 26, 2026 18:11
Previously, the encoder rejected invalid chunks in indefinite-length
strings based on the Go type. This could mistakenly reject objects
that don't match the expected Go type, even if they encode valid chunk
data (e.g., with a user-defined CBORMarshaler), and vice versa.

This commit validates a chunk by inspecting the encoded chunk's CBOR
type to ensure that the encoded chunk data is definite-length items
of the same major type as the parent.
@fxamacker fxamacker merged commit e6af0aa into master Apr 27, 2026
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix improvement improvement that does not add new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants