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 decoding option to allow invalid UTF-8 #342

Conversation

fxamacker
Copy link
Owner

Description

Add DecOptions.UTF8 to specify how to decode invalid UTF-8:

  • UTF8RejectInvalid (default) returns SemanticError on invalid UTF-8
  • UTF8DecodeInvalid decodes invalid UTF-8

Since CBOR text containing invalid UTF-8 isn't valid, decoder by default
rejects it and returns error.

This option is backward compatible by default.

See RFC 8949 Section 5.3 (Validity of Items) for more info.

Closes #320

Add DecOptions.UTF8 to specify how to decode invalid UTF-8:
- UTF8RejectInvalid (default) returns SemanticError on invalid UTF-8
- UTF8DecodeInvalid decodes invalid UTF-8

Since CBOR text containing invalid UTF-8 isn't valid, decoder by default
rejects it and returns error.

This option is backward compatible by default.

See RFC 8949 Section 5.3 (Validity of Items) for more info.
@fxamacker fxamacker added the enhancement New feature or request label May 15, 2022
@fxamacker fxamacker self-assigned this May 15, 2022
@fxamacker
Copy link
Owner Author

@x448 This is a port from stream-mode branch. Can you review in case I missed anything?

Copy link
Contributor

@x448 x448 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM but please mention new option in README.md.

@fxamacker fxamacker merged commit 5b9c681 into master May 15, 2022
@fxamacker fxamacker deleted the fxamacker/add-decode-option-for-invalid-utf8-in-nonstreammode branch May 15, 2022 17:58
@fxamacker fxamacker added this to the v2.5.0 milestone Aug 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feature: Add decoder option (non-default) to allow decoding CBOR text string containing invalid UTF-8
2 participants