From bea2e36962bc30cc7b8ca396665d2bd716b8d7e2 Mon Sep 17 00:00:00 2001 From: Shulhan Date: Mon, 18 Dec 2023 23:50:50 +0700 Subject: ssh/config: set default section name to '*' if parameter is empty --- lib/ssh/config/section.go | 5 +++++ lib/ssh/config/section_match_test.go | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'lib/ssh') diff --git a/lib/ssh/config/section.go b/lib/ssh/config/section.go index 7f6c6126..8e3c3f00 100644 --- a/lib/ssh/config/section.go +++ b/lib/ssh/config/section.go @@ -224,6 +224,11 @@ type Section struct { // NewSection create new Host or Match with default values. func NewSection(name string) *Section { + name = strings.TrimSpace(name) + if len(name) == 0 { + name = `*` + } + return &Section{ Field: map[string]string{ KeyChallengeResponseAuthentication: ValueYes, diff --git a/lib/ssh/config/section_match_test.go b/lib/ssh/config/section_match_test.go index f976afd7..5a40051f 100644 --- a/lib/ssh/config/section_match_test.go +++ b/lib/ssh/config/section_match_test.go @@ -43,7 +43,7 @@ func TestParseCriteriaAll(t *testing.T) { }{{ raw: "all ", exp: func(exp Section) *Section { - exp.name = `all ` + exp.name = `all` exp.criteria = []*matchCriteria{{ name: criteriaAll, }} -- cgit v1.3-5-g9baa