diff options
author | Rubén Dávila <ruben@gitlab.com> | 2018-02-15 09:50:19 -0500 |
---|---|---|
committer | Rubén Dávila <ruben@gitlab.com> | 2018-02-15 09:50:19 -0500 |
commit | 75fd83245450216b0aeec9993455802764eaf87b (patch) | |
tree | 8892a4c9e970d5a6d3bd767c8788bce93734388a /app/models/key.rb | |
parent | 1bbce21f644809532454101adaa49039711cf86b (diff) | |
download | gitlab-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/models/key.rb')
-rw-r--r-- | app/models/key.rb | 7 |
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 |