diff options
| author | Shulhan <ms@kilabit.info> | 2023-12-18 23:50:50 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2023-12-19 00:11:01 +0700 |
| commit | bea2e36962bc30cc7b8ca396665d2bd716b8d7e2 (patch) | |
| tree | bc0a577f961b284f1a9c3f62b28fd968b9d69fa1 /lib/ssh | |
| parent | 7e8c9fe819223b44da3f608a39c507d0f9873747 (diff) | |
| download | pakakeh.go-bea2e36962bc30cc7b8ca396665d2bd716b8d7e2.tar.xz | |
ssh/config: set default section name to '*' if parameter is empty
Diffstat (limited to 'lib/ssh')
| -rw-r--r-- | lib/ssh/config/section.go | 5 | ||||
| -rw-r--r-- | lib/ssh/config/section_match_test.go | 2 |
2 files changed, 6 insertions, 1 deletions
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, }} |
