fix: respect immutable flag for unknown semantic tags#321
Closed
gaoflow wants to merge 2 commits into
Closed
Conversation
The decoder returned the internal break-marker sentinel to the caller whenever a break code (major type 7, subtype 31 / 0xff) appeared where a data item was expected: at the top level (a naked break), as a definite-length array element or map key/value, and as the content of a tag, shareable or string-reference namespace. RFC 8949 sect. 3.2.1 defines such input as not well-formed, so the decoder must reject it. A break code is only a legal terminator inside an indefinite-length array or map (indefinite-length strings consume it internally). Mark those two frame types as accepting a break and reject a break that reaches any other frame, as well as one left as the top-level result. Fixes agronholm#305.
When a CBOR tag wraps content like a map, the decoder always set requested_immutable=true for the BeginFrame, causing the inner map to always be decoded as frozendict regardless of the immutable argument. Use the immutable parameter from decode_semantic instead of hardcoding true, so the user's immutable preference is respected. Fixes: agronholm#296 Signed-off-by: Vincent Gao <gaobing1230@gmail.com>
Owner
|
This looks like an AI-generated slop PR. |
Owner
|
Oh, and besides, it's a duplicate of #312. |
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.
When a CBOR tag wraps a map, the decoder hardcoded
requested_immutable=truewhen creating the BeginFrame for the tag'sinner content. This forced the inner map to always decode as
frozendictregardless of theimmutableargument passed to thedecoder.
Change
trueto theimmutableparameter fromdecode_semantic,so the user's preference is respected:
immutable=False(default) → regulardictimmutable=True→frozendictFixes: #296