aboutsummaryrefslogtreecommitdiffstats
path: root/models/ssh_key.go
diff options
context:
space:
mode:
authorJohn Maguire <contact@johnmaguire.me>2016-01-31 22:00:55 -0500
committerJohn Maguire <contact@johnmaguire.me>2016-01-31 22:02:36 -0500
commitb3e0efc0c39f231b2f32105e15b43c26cc3d32f6 (patch)
tree7e906ae3c2e8f50ff348921430754264c8f2b8cc /models/ssh_key.go
parentcaa4ca46c0d4cb7b29e5702679b1ce70b7a2c178 (diff)
downloadgitea-b3e0efc0c39f231b2f32105e15b43c26cc3d32f6.tar.gz
gitea-b3e0efc0c39f231b2f32105e15b43c26cc3d32f6.zip
Trim whitespace when adding SSH keys (fixes #2447)
Diffstat (limited to 'models/ssh_key.go')
-rw-r--r--models/ssh_key.go3
1 files changed, 3 insertions, 0 deletions
diff --git a/models/ssh_key.go b/models/ssh_key.go
index 471f4cd12c..325a40a481 100644
--- a/models/ssh_key.go
+++ b/models/ssh_key.go
@@ -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")