protobuf.js
protobuf.js copied to clipboard
Fix encoding of int64/bool keys of maps in encoder
Fixes #1652 .
The int64 writer cannot handle the hash directly, because it interprets it as a string representation of a Long number, instead of a hash.
This is obviously wrong, because the input at this point always contains the longbit hashes already. So the int64() writer fails inevitably.
I believe that the simplest solution is: Explicit conversion from hash to long is needed before writing.
Again (just like with the other PR I submitted) I believe that the tests are missing for the generated encode/decode functions. If there were such tests, it would be fairly straightforward to write a test case that exercises this problem, and proves that the fix, in fact, works.
Exactly same case with a bool key type. Fix extended to cover this case as well.