Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TrimSpace when reading InternalToken from a file (#11502) #11524

Merged
merged 1 commit into from
May 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 20 additions & 3 deletions cmd/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ package cmd

import (
"fmt"
"os"

"code.gitea.io/gitea/modules/generate"

"github.com/mattn/go-isatty"
"github.com/urfave/cli"
)

Expand Down Expand Up @@ -59,7 +61,12 @@ func runGenerateInternalToken(c *cli.Context) error {
return err
}

fmt.Printf("%s\n", internalToken)
fmt.Printf("%s", internalToken)

if isatty.IsTerminal(os.Stdout.Fd()) {
fmt.Printf("\n")
}

return nil
}

Expand All @@ -69,7 +76,12 @@ func runGenerateLfsJwtSecret(c *cli.Context) error {
return err
}

fmt.Printf("%s\n", JWTSecretBase64)
fmt.Printf("%s", JWTSecretBase64)

if isatty.IsTerminal(os.Stdout.Fd()) {
fmt.Printf("\n")
}

return nil
}

Expand All @@ -79,6 +91,11 @@ func runGenerateSecretKey(c *cli.Context) error {
return err
}

fmt.Printf("%s\n", secretKey)
fmt.Printf("%s", secretKey)

if isatty.IsTerminal(os.Stdout.Fd()) {
fmt.Printf("\n")
}

return nil
}
2 changes: 1 addition & 1 deletion modules/setting/setting.go
Original file line number Diff line number Diff line change
Expand Up @@ -1069,7 +1069,7 @@ func loadInternalToken(sec *ini.Section) string {
return token
}

return string(buf)
return strings.TrimSpace(string(buf))
default:
log.Fatal("Unsupported URI-Scheme %q (INTERNAL_TOKEN_URI = %q)", tempURI.Scheme, uri)
}
Expand Down