Skip to content

Commit

Permalink
Fix config parser to properly allow equals in all arguments
Browse files Browse the repository at this point in the history
This commit fixes the config file parser to allow an optional equals
sign as an argument separator for all arguments. The previous code
allowed this for the first argument on a line, but not later ones.
  • Loading branch information
ronf committed Dec 3, 2023
1 parent dd00628 commit a788cfb
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions asyncssh/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,22 +315,26 @@ def parse(self, path: Path) -> None:
continue

try:
args = shlex.split(line)
split_args = shlex.split(line)
except ValueError as exc:
self._error(str(exc))

option = args.pop(0)

if option.endswith('='):
option = option[:-1]
elif '=' in option:
option, arg = option.split('=', 1)
args[:0] =[arg]
elif args and args[0] == '=':
del args[0]
elif args and args[0].startswith('='):
args[0] = args[0][1:]
args = []

for arg in split_args:
if arg.startswith('='):
if len(arg) > 1:
args.append(arg[1:])
elif arg.endswith('='):
args.append(arg[:-1])
elif '=' in arg:
arg, val = arg.split('=', 1)
args.append(arg)
args.append(val)
else:
args.append(arg)

option = args.pop(0)
loption = option.lower()

if loption in self._no_split:
Expand Down

0 comments on commit a788cfb

Please sign in to comment.