Use `strings.Cut` for GIT_PROTOCOL value (#20638)

- As per https://github.com/go-gitea/gitea/pull/20616#discussion_r935612542
tokarchuk/v1.18
Gusted 2 years ago committed by GitHub
parent 90b2657ae7
commit 87a7c37ecb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      modules/ssh/ssh.go

@ -78,8 +78,7 @@ func sessionHandler(session ssh.Session) {
gitProtocol := "" gitProtocol := ""
for _, env := range session.Environ() { for _, env := range session.Environ() {
if strings.HasPrefix(env, "GIT_PROTOCOL=") { if strings.HasPrefix(env, "GIT_PROTOCOL=") {
// The value would be version=2, so using normal split doesn't work here. _, gitProtocol, _ = strings.Cut(env, "=")
gitProtocol = strings.SplitN(env, "=", 2)[1]
break break
} }
} }

Loading…
Cancel
Save