diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2023-12-06 17:02:13 +0100 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2023-12-07 12:57:25 +0100 |
commit | cca6c4c6986abc67cd213ad1d32d329384a57790 (patch) | |
tree | 7582bde2a49bcd6c171e7a008aef075cb63a5da8 /src/nvim/api/private | |
parent | 5fa88a7ae13effc02d42070313d3082bf98e22a7 (diff) | |
download | rneovim-cca6c4c6986abc67cd213ad1d32d329384a57790.tar.gz rneovim-cca6c4c6986abc67cd213ad1d32d329384a57790.tar.bz2 rneovim-cca6c4c6986abc67cd213ad1d32d329384a57790.zip |
feat(rpc): allow empty string key in msgpack => Vim conversion
Problem:
Since e057b38e7037 #20757 we support empty key in JSON encode/decode,
but we don't allow it in RPC object => Vim dict conversion. But empty
string is a valid key in Vim dicts and the msgpack spec.
Empty string key was disallowed in 7c01d5ff9286 (2014) but that
commit/PR doesn't explicitly discuss it, so presumably it was a "seems
reasonable" decision (or Vimscript didn't allow empty keys until later).
Solution:
Remove the check in `object_to_vim()`. Note that
`tv_dict_item_alloc_len` will invoke `memcpy(…, 0)` but that's allowed
by the C spec: https://stackoverflow.com/a/3751937/152142
Diffstat (limited to 'src/nvim/api/private')
-rw-r--r-- | src/nvim/api/private/converter.c | 9 |
1 files changed, 0 insertions, 9 deletions
diff --git a/src/nvim/api/private/converter.c b/src/nvim/api/private/converter.c index ef57bde32d..1e11683c38 100644 --- a/src/nvim/api/private/converter.c +++ b/src/nvim/api/private/converter.c @@ -328,15 +328,6 @@ bool object_to_vim(Object obj, typval_T *tv, Error *err) for (uint32_t i = 0; i < obj.data.dictionary.size; i++) { KeyValuePair item = obj.data.dictionary.items[i]; String key = item.key; - - if (key.size == 0) { - api_set_error(err, kErrorTypeValidation, - "Empty dictionary keys aren't allowed"); - // cleanup - tv_dict_free(dict); - return false; - } - dictitem_T *const di = tv_dict_item_alloc(key.data); if (!object_to_vim(item.value, &di->di_tv, err)) { |