return
}
- if ok, err := models.CheckPublicKeyString(form.Content); !ok {
+ // Remove newline characters from form.KeyContent
+ cleanKeyContent := strings.Replace(form.KeyContent, "\n", "", -1),
+
+ if ok, err := models.CheckPublicKeyString(cleanKeyContent); !ok {
ctx.Flash.Error(ctx.Tr("form.invalid_ssh_key", err.Error()))
ctx.Redirect("/user/settings/ssh")
return
k := &models.PublicKey{
OwnerId: ctx.User.Id,
Name: form.SSHTitle,
- Content: form.Content,
+ Content: cleanKeyContent,
}
if err := models.AddPublicKey(k); err != nil {
if err == models.ErrKeyAlreadyExist {