summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorRubén Dávila <ruben@gitlab.com>2018-02-15 09:50:19 -0500
committerRubén Dávila <ruben@gitlab.com>2018-02-15 09:50:19 -0500
commit75fd83245450216b0aeec9993455802764eaf87b (patch)
tree8892a4c9e970d5a6d3bd767c8788bce93734388a /app
parent1bbce21f644809532454101adaa49039711cf86b (diff)
downloadgitlab-ce-75fd83245450216b0aeec9993455802764eaf87b.tar.gz
Revert "Merge branch 'rd-43185-revert-sanitize-extra-blank-spaces-used-when-uploading-a-ssh-key' into 'master'"
This reverts commit e607fd796657afd214b8f25201919d3e33b3f35f.
Diffstat (limited to 'app')
-rw-r--r--app/models/key.rb7
1 files changed, 3 insertions, 4 deletions
diff --git a/app/models/key.rb b/app/models/key.rb
index 7406c98c99e..ae5769c0627 100644
--- a/app/models/key.rb
+++ b/app/models/key.rb
@@ -33,9 +33,8 @@ class Key < ActiveRecord::Base
after_destroy :refresh_user_cache
def key=(value)
- value&.delete!("\n\r")
- value.strip! unless value.blank?
- write_attribute(:key, value)
+ write_attribute(:key, value.present? ? Gitlab::SSHPublicKey.sanitize(value) : nil)
+
@public_key = nil
end
@@ -97,7 +96,7 @@ class Key < ActiveRecord::Base
def generate_fingerprint
self.fingerprint = nil
- return unless self.key.present?
+ return unless public_key.valid?
self.fingerprint = public_key.fingerprint
end