diff options
| author | Volodymyr Chernetskyi <volodymyr_chernetskyi@goodyear.com> | 2026-09-03 12:40:58 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-09-03 06:40:58 -0400 |
| commit | 73923b0dd85bb936ba2f63ee916dabaa0603340d (patch) | |
| tree | d818ba878083fcdbc318aee42cb298c2f5232148 /runtime/lua/vim/net/_ssh.lua | |
| parent | 51eacf284c72558be43aa6beebbbcfae45cf4920 (diff) | |
| download | rneovim-73923b0dd85bb936ba2f63ee916dabaa0603340d.tar.gz rneovim-73923b0dd85bb936ba2f63ee916dabaa0603340d.tar.bz2 rneovim-73923b0dd85bb936ba2f63ee916dabaa0603340d.zip | |
fix(ssh): compare table length in the SSH config #41637
Problem:
`parse_ssh_config()` compares tables against a freshly allocated empty
table.
- In `parse_multiple_values()`, the guard which avoids flushing an empty
accumulator never applies. Runs of separators and trailing whitespace
push empty strings into the results, and `is_valid()` does not filter
them. `Host alpha beta ` parses as `{ 'alpha', '', 'beta' }`.
- In `parse_value()`, the condition reduces to `chr == '"' and quoted`.
`quoted` starts false and only that branch sets it, so it can never
become true: quotes are never recognised and are inserted literally,
and the unterminated-quote check is unreachable.
Solution:
Compare `#val` instead. Add a test for repeated and trailing separators.
AI-assisted
Diffstat (limited to 'runtime/lua/vim/net/_ssh.lua')
| -rw-r--r-- | runtime/lua/vim/net/_ssh.lua | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/runtime/lua/vim/net/_ssh.lua b/runtime/lua/vim/net/_ssh.lua index 3f18213244..6bf55423f4 100644 --- a/runtime/lua/vim/net/_ssh.lua +++ b/runtime/lua/vim/net/_ssh.lua @@ -84,7 +84,7 @@ function M.parse_ssh_config(text) if escaped then table.insert(val, chr == '"' and chr or '\\' .. chr) escaped = false - elseif chr == '"' and (val == {} or quoted) then + elseif chr == '"' and (#val == 0 or quoted) then quoted = not quoted elseif chr == '\\' then escaped = true @@ -127,7 +127,7 @@ function M.parse_ssh_config(text) elseif quoted then table.insert(val, chr) elseif chr:match('[ \t=]') then - if val ~= {} then + if #val > 0 then table.insert(results, vim.trim(table.concat(val))) val = {} end @@ -143,7 +143,7 @@ function M.parse_ssh_config(text) error('Unexpected line break at line ' .. line) end - if val ~= {} then + if #val > 0 then table.insert(results, vim.trim(table.concat(val))) end |