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

Allow decoding raw strings #235

Merged
merged 3 commits into from
Jan 26, 2025
Merged

Conversation

jasonpaulos
Copy link
Contributor

This PR adds the ability to skip UTF-8 decoding of strings when you enable the rawStrings decoding option.

This is useful because I have encountered some encoded msgpack strings which do not contain valid UTF-8 data, and without a feature like this, it would be impossible to decode them properly.

According to the msgpack spec, this ability is encouraged:

  • String objects may contain invalid byte sequence and the behavior of a deserializer depends on the actual implementation when it received invalid byte sequence
    • Deserializers should provide functionality to get the original byte array so that applications can decide how to handle the object

Comment on lines +29 to +31
* Note that this option only applies to string values, not map keys. Additionally, when
* enabled, raw string length is limited by the maxBinLength option.
*/
Copy link

@jannotti jannotti Oct 30, 2023

Choose a reason for hiding this comment

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

Why not do this for map keys as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This library doesn't support binary keys, so I decided to skip that case.

Copy link
Member

Choose a reason for hiding this comment

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

No, it doesn't. Sounds a good decision.

@gfx
Copy link
Member

gfx commented Jan 26, 2025

Sorry for the delayed response. Thanks for your contribution. LGTM.

@codecov-commenter
Copy link

codecov-commenter commented Jan 26, 2025

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.07%. Comparing base (3783cf4) to head (3b6ef80).
Report is 25 commits behind head on main.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #235      +/-   ##
==========================================
- Coverage   98.55%   98.07%   -0.48%     
==========================================
  Files          16       16              
  Lines        1037     1092      +55     
  Branches      200      249      +49     
==========================================
+ Hits         1022     1071      +49     
- Misses         15       21       +6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@gfx gfx merged commit 0bb101d into msgpack:main Jan 26, 2025
8 checks passed
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.

None yet

4 participants