mirror of
https://github.com/neovim/neovim.git
synced 2026-04-26 01:04:10 +00:00
fix(messages): disallow user-defined integer message-id #38359
Problem:
`nvim_echo(…, {id=…})` accepts user-defined id as a string or integer.
Generated ids are always higher than last highest msg-id used. Thus
plugins may accidentally advance the integer id "address space", which,
at minimum, could lead to confusion when troubleshooting, or in the
worst case, could overflow or "exhaust" the id address space.
There's no use-case for it, and it could be the mildly confusing, so we
should just disallow it.
Solution:
Disallow *integer* user-defined message-id.
Only allow *string* user-defined message-id.
This commit is contained in:
@@ -3821,6 +3821,11 @@ describe('API', function()
|
||||
pcall_err(api.nvim_echo, { { '', '', '' } }, 1, {})
|
||||
)
|
||||
eq("Invalid 'hl_group': 'text highlight'", pcall_err(api.nvim_echo, { { '', false } }, 1, {}))
|
||||
eq("Invalid 'id': 4", pcall_err(api.nvim_echo, { { 'foo' } }, false, { id = 4 }))
|
||||
eq("Invalid 'id': 0", pcall_err(api.nvim_echo, { { 'foo' } }, false, { id = 0 }))
|
||||
eq("Invalid 'id': -1", pcall_err(api.nvim_echo, { { 'foo' } }, false, { id = -1 }))
|
||||
-- String ids are always allowed (user-defined).
|
||||
eq('my.msg.id', api.nvim_echo({ { 'foo' } }, false, { id = 'my.msg.id' }))
|
||||
end)
|
||||
|
||||
it('should clear cmdline message before echo', function()
|
||||
@@ -3913,8 +3918,8 @@ describe('API', function()
|
||||
|
||||
it('increments message ID', function()
|
||||
eq(1, api.nvim_echo({ { 'foo' } }, false, {}))
|
||||
eq(4, api.nvim_echo({ { 'foo' } }, false, { id = 4 }))
|
||||
eq(5, api.nvim_echo({ { 'foo' } }, false, {}))
|
||||
eq(1, api.nvim_echo({ { 'foo' } }, false, { id = 1 })) -- User may pass existing id.
|
||||
eq(2, api.nvim_echo({ { 'foo' } }, false, {}))
|
||||
end)
|
||||
|
||||
it('no use-after-free for custom kind with :messages #38289', function()
|
||||
|
||||
Reference in New Issue
Block a user