Cannot encode array of empty string
SevereOverfl0w opened this issue · 7 comments
This test case fails:
var msgpack = require('msgpack5')();
msgpack.encode([""], true);
It's particularly a pain being felt far downstream (a dependent, of a dependent, of a dependent).
Is it caused by misuse of the library (there was a version upgrade to fix an alternative bug some time ago)? Or should this work?
I do not think that is covered by the automated test suite (https://github.com/mcollina/msgpack5/blob/master/test/1-byte-length-strings.js). So, probably not.
Feel free to send a pull request with unit tests.
Sorry, I worded that poorly.
It isn't a test from the suite, but an example of code which throws an exception.
I can attempt to PR a unit test, but I think it will fail due to the code throwing an exception.
@SevereOverfl0w then add a fix as well!
I don't understand the problem with the input very well, I don't know anything about msgpack encoding.
Could you give me some pointers?
Here is the culprit: https://github.com/mcollina/msgpack5/blob/master/lib/encoder.js#L20-L25!