From 8da919649116a84daa138155bac1fd5c6546078e Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Sun, 3 Oct 2021 08:09:04 -0700 Subject: [PATCH] ssh: Host is space delimited, not comma delimited closes: #1196 --- docs/changelog.md | 1 + wezterm-ssh/src/config.rs | 18 +++++++++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/docs/changelog.md b/docs/changelog.md index bd21e8734..380d7af2c 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -54,6 +54,7 @@ As features stabilize some brief notes about them will accumulate here. * New: `wezterm connect` now also supports the `--class` parameter to override the window class * Fixed: wezterm can now match bitmap fonts that are spread across multiple font files [#1189](https://github.com/wez/wezterm/issues/1189) * Improved: [use_cap_height_to_scale_fallback_fonts](config/lua/config/use_cap_height_to_scale_fallback_fonts.md) now computes *cap-height* based on the rasterized glyph bitmap which means that the data is accurate in more cases, including for bitmap fonts. Scaling is now also applied to across varying text styles; previously it only applied to a font within an `wezterm.font_with_fallback` font list. +* Fixed: ssh config parser incorrectly split `Host` patterns with commas instead of whitespace [#1196](https://github.com/wez/wezterm/issues/1196) ### 20210814-124438-54e29167 diff --git a/wezterm-ssh/src/config.rs b/wezterm-ssh/src/config.rs index 1e4bfd097..354b34d46 100644 --- a/wezterm-ssh/src/config.rs +++ b/wezterm-ssh/src/config.rs @@ -236,6 +236,18 @@ impl ParsedConfigFile { } patterns } + fn parse_whitespace_pattern_list(v: &str) -> Vec { + let mut patterns = vec![]; + for p in v.split_ascii_whitespace() { + let p = p.trim(); + if p.starts_with('!') { + patterns.push(Pattern::new(&p[1..], true)); + } else { + patterns.push(Pattern::new(p, false)); + } + } + patterns + } if k == "include" { Self::do_include(v, cwd, options, groups); @@ -243,7 +255,7 @@ impl ParsedConfigFile { } if k == "host" { - let patterns = parse_pattern_list(v); + let patterns = parse_whitespace_pattern_list(v); groups.push(MatchGroup { criteria: vec![Criteria::Host(patterns)], options: ConfigMap::new(), @@ -1026,11 +1038,11 @@ Config { Something first # the prior Something takes precedence Something ignored - Host 192.168.1.8,wopr + Host 192.168.1.8 wopr FowardAgent yes IdentityFile "%d/.ssh/id_pub.dsa" - Host !a.b,*.b + Host !a.b *.b ForwardAgent no IdentityAgent "${HOME}/.ssh/agent"