diff options
author | John Maguire <contact@johnmaguire.me> | 2016-01-31 22:00:55 -0500 |
---|---|---|
committer | John Maguire <contact@johnmaguire.me> | 2016-01-31 22:02:36 -0500 |
commit | b3e0efc0c39f231b2f32105e15b43c26cc3d32f6 (patch) | |
tree | 7e906ae3c2e8f50ff348921430754264c8f2b8cc | |
parent | caa4ca46c0d4cb7b29e5702679b1ce70b7a2c178 (diff) | |
download | gitea-b3e0efc0c39f231b2f32105e15b43c26cc3d32f6.tar.gz gitea-b3e0efc0c39f231b2f32105e15b43c26cc3d32f6.zip |
Trim whitespace when adding SSH keys (fixes #2447)
-rw-r--r-- | models/ssh_key.go | 3 |
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") |