]> source.dussan.org Git - gitea.git/commitdiff
Trim whitespace when adding SSH keys (fixes #2447)
authorJohn Maguire <contact@johnmaguire.me>
Mon, 1 Feb 2016 03:00:55 +0000 (22:00 -0500)
committerJohn Maguire <contact@johnmaguire.me>
Mon, 1 Feb 2016 03:02:36 +0000 (22:02 -0500)
models/ssh_key.go

index 471f4cd12c8256bf16bbb1aa2d4348ba86e5bc30..325a40a4815d876ffce0e1c711f01b57519a8c42 100644 (file)
@@ -165,6 +165,9 @@ func CheckPublicKeyString(content string) (_ string, err error) {
                return "", errors.New("only a single line with a single key please")
        }
 
+       // remove any unnecessary whitespace now
+       content = strings.TrimSpace(content)
+
        fields := strings.Fields(content)
        if len(fields) < 2 {
                return "", errors.New("too less fields")