Comments (7)
Thanks.
No need to send a minimal test case. I see the error. I'd upload a fix pronto.
from go.
Thanks!
from go.
Sorry, quick question, will the conversion of []byte to string potentially cause problems if the data is not UTF8 format?
from go.
The latest commit does fix our issue though. Thanks for the quick turn around!
from go.
Please re-test and confirm fix.
No - it will not cause an issue.
This is in line with the old logic before (see kMap method). We special-case and fast-tracked some common map types, and I forgot to replicate that check in there.
The reason for doing this, is that the original msgpack encodes a string as raw []byte (there was no separate string or binary type). When decoding, we need to make a determination what to do when we see raw bytes. We use the following to make that determination:
- If we see raw bytes as key in a map, then it must have been a string (because Go doesn't support slices as map keys). So we just convert it to a string (else you get the error you received that hashmap cannot have a slice as a key value because slices do not support equality).
- In any other situation that we see raw bytes in the stream, we use the value of the Option RawToString
to determine what to do (either keep as []byte or convert to string).
A string in Go is just an immutable string of bytes - it doesn't specify an encoding. There are libs to treat it as utf8, utf16, runes (utf-32), etc.
from go.
And thanks for reporting this quickly. Much appreciated. I pride myself on not overlooking things, and am happy you caught this one for me quickly before others ran across it, and wasted time checking if the problem was on their end.
from go.
Thanks for the response and the excellent library! Cheers.
from go.
Related Issues (20)
- omitempty handling for arrays disagrees with the standard encoding/json HOT 2
- codec.MsgpackHandle.RawToString is confusingly named HOT 2
- Go 1.20 - invalid memory address or nil pointer dereference HOT 5
- Msgpack deserialization with codecgen produces wrong result HOT 3
- Unexpected encoding with interface{} key using Canonical and MapKeyAsString.
- Decoding a slice of structs encoded as arrays into a slice of structs without the same number of fields HOT 2
- Duplicate key inside of a map triggers a "cannot decode unsigned integer" msgpack decode error HOT 1
- Efficient direct conversion between supported formats? HOT 2
- Expose Handle.Name() in some form through Encoder and Decoder for use by codec.Selfer HOT 1
- `io.ErrUnexpectedEOF` should be returned instead of `io.EOF` when only partial data is present
- Add `DecodeOptions.IntType` and `DecodeOptions.FloatType` ? HOT 1
- Docs do not seem to mention case-sensitive field handling
- mem leak? HOT 1
- Tests use rand.Intn(1) for boolean rand, but always returns 0
- Decoder accepts indefinite-length CBOR strings containing chunks with mismatched major types HOT 1
- UTF-8 validation isn't applied to CBOR text strings nested inside an indefinite-length text string HOT 2
- Add support for github.com/go-json-experiment/json / UnmarshalerV2 ? HOT 1
- runtime error with golang master (furture go 1.22)
- Leading zeros is not allowed in rfc7159
- attr.go
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from go.