Skip to content

fix: respect immutable flag for unknown semantic tags#321

Closed
gaoflow wants to merge 2 commits into
agronholm:masterfrom
gaoflow:fix-296-tag-immutable
Closed

fix: respect immutable flag for unknown semantic tags#321
gaoflow wants to merge 2 commits into
agronholm:masterfrom
gaoflow:fix-296-tag-immutable

Conversation

@gaoflow

@gaoflow gaoflow commented Jun 18, 2026

Copy link
Copy Markdown

When a CBOR tag wraps a map, the decoder hardcoded
requested_immutable=true when creating the BeginFrame for the tag's
inner content. This forced the inner map to always decode as
frozendict regardless of the immutable argument passed to the
decoder.

Change true to the immutable parameter from decode_semantic,
so the user's preference is respected:

  • immutable=False (default) → regular dict
  • immutable=Truefrozendict

Fixes: #296

gaoflow added 2 commits June 16, 2026 01:41
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>
@coveralls

Copy link
Copy Markdown

Coverage Status

coverage: 94.724% (+0.07%) from 94.659% — gaoflow:fix-296-tag-immutable into agronholm:master

@agronholm

Copy link
Copy Markdown
Owner

This looks like an AI-generated slop PR.

@agronholm

Copy link
Copy Markdown
Owner

Oh, and besides, it's a duplicate of #312.

@agronholm agronholm closed this Jun 18, 2026
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.

Tag values always decoded as immutable

3 participants