aboutsummaryrefslogtreecommitdiff
path: root/routers
diff options
context:
space:
mode:
authorUnknwon <joe2010xtmf@163.com>2014-08-26 18:11:27 +0800
committerUnknwon <joe2010xtmf@163.com>2014-08-26 18:11:27 +0800
commit50de06056be67ab8433fa796608e38004f2e8733 (patch)
tree5047f12a9aa9fa454a2ff1ca106255ea3ad87b26 /routers
parent74b31566cf5caaf6bf73584e621d56ca99c048d1 (diff)
parent66c9c86219b66baa1c6db1543a04494bda3f39c4 (diff)
Merge branch 'dev' of github.com:gogits/gogs into dev
Diffstat (limited to 'routers')
-rw-r--r--routers/user/setting.go9
1 files changed, 7 insertions, 2 deletions
diff --git a/routers/user/setting.go b/routers/user/setting.go
index e091bc43..d3b79213 100644
--- a/routers/user/setting.go
+++ b/routers/user/setting.go
@@ -5,6 +5,8 @@
package user
import (
+ "strings"
+
"github.com/Unknwon/com"
"github.com/gogits/gogs/models"
@@ -171,7 +173,10 @@ func SettingsSSHKeysPost(ctx *middleware.Context, form auth.AddSSHKeyForm) {
return
}
- if ok, err := models.CheckPublicKeyString(form.Content); !ok {
+ // Remove newline characters from form.KeyContent
+ cleanContent := strings.Replace(form.Content, "\n", "", -1)
+
+ if ok, err := models.CheckPublicKeyString(cleanContent); !ok {
ctx.Flash.Error(ctx.Tr("form.invalid_ssh_key", err.Error()))
ctx.Redirect("/user/settings/ssh")
return
@@ -180,7 +185,7 @@ func SettingsSSHKeysPost(ctx *middleware.Context, form auth.AddSSHKeyForm) {
k := &models.PublicKey{
OwnerId: ctx.User.Id,
Name: form.SSHTitle,
- Content: form.Content,
+ Content: cleanContent,
}
if err := models.AddPublicKey(k); err != nil {
if err == models.ErrKeyAlreadyExist {