Skip to content

Commit

Permalink
Fix issue with parsing the SSH config file
Browse files Browse the repository at this point in the history
This commit fixes a previous parsing change that made the code too
aggressive about converting equals sign delimiters to spaces. Thanks
go to Siddh Raman Pant for reporting this issue!
  • Loading branch information
ronf committed May 31, 2024
1 parent 43bcd2d commit 9ad9688
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions asyncssh/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,8 +320,9 @@ def parse(self, path: Path) -> None:
self._error(str(exc))

args = []
loption = ''

for arg in split_args:
for i, arg in enumerate(split_args, 1):
if arg.startswith('='):
if len(arg) > 1:
args.append(arg[1:])
Expand All @@ -334,8 +335,11 @@ def parse(self, path: Path) -> None:
else:
args.append(arg)

option = args.pop(0)
loption = option.lower()
if i == 1:
loption = args.pop(0).lower()
elif i > 1 and loption not in self._conditionals:
args.extend(split_args[i:])
break

if loption in self._no_split:
args = [line.lstrip()[len(loption):].strip()]
Expand Down Expand Up @@ -562,7 +566,7 @@ def _set_tokens(self) -> None:
('SendEnv', SSHConfig._append_string_list),
('ServerAliveCountMax', SSHConfig._set_int),
('ServerAliveInterval', SSHConfig._set_int),
('SetEnv', SSHConfig._append_string_list),
('SetEnv', SSHConfig._set_string_list),
('Tag', SSHConfig._set_string),
('TCPKeepAlive', SSHConfig._set_bool),
('User', SSHConfig._set_string),
Expand Down

0 comments on commit 9ad9688

Please sign in to comment.