Sitelet https://github.com/tejaycar/chef-ssh/commit/0fc7cc25e608f85a3e59da4c93592c601d5d5235
Skip to content

Commit 0fc7cc2

Browse files
committed
Adapt regex for HostName option when parsing file
Old regex match "HostName ..." as a Host entry that generate an invalid ssh configuration file.
1 parent ecfad2f commit 0fc7cc2

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

‎libraries/ssh_config_helpers.rb‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def parse_file(path)
1919
IO.foreach(path) do |line|
2020
next if line.match(/^\s*(#|\r?\n|\s*$)/) # skip lines with only comments or whitespace
2121

22-
matchdata = line.match(/^\s*([h|H]ost)(.*$)/)
22+
matchdata = line.match(/^\s*([h|H]ost\s)(.*$)/)
2323
if matchdata
2424
name = matchdata.captures[1].strip
2525
entries[name] = {}

‎spec/provider_tests/config_spec.rb‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
content << 'and_also_with=equal sign'
2222
content << 'Host second with extra patterns'
2323
content << ' Extra_spaces did_not_matter'
24+
content << ' HostName option is correctly matched'
2425
content << ' Multiple_words not a problem'
2526
content << ' We "can handle quotes"'
2627
end
@@ -39,6 +40,7 @@
3940
content << ''
4041
content << 'Host second with extra patterns'
4142
content << ' Extra_spaces did_not_matter'
43+
content << ' HostName option is correctly matched'
4244
content << ' Multiple_words not a problem'
4345
content << ' We "can handle quotes"'
4446
content << ''

0 commit comments

Comments
 (0)