diff options
author | haseeb <haseebeqx@gmail.com> | 2017-08-03 19:39:10 +0300 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2017-08-03 19:39:10 +0300 |
commit | ae99f05b059f613296c39dfa45c37dbcab40f4cd (patch) | |
tree | 1b067be3bd6879727efc2a5d94d2d16880c928d3 /app/models/key.rb | |
parent | 118dcff0351363426c7ac1cb3e459b001f2f9a47 (diff) |
fix #35133 strip new lines from ssh keys
Diffstat (limited to 'app/models/key.rb')
-rw-r--r-- | app/models/key.rb | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/app/models/key.rb b/app/models/key.rb index cb8f10f6d55..49bc26122fa 100644 --- a/app/models/key.rb +++ b/app/models/key.rb @@ -16,8 +16,6 @@ class Key < ActiveRecord::Base presence: true, length: { maximum: 5000 }, format: { with: /\A(ssh|ecdsa)-.*\Z/ } - validates :key, - format: { without: /\n|\r/, message: 'should be a single line' } validates :fingerprint, uniqueness: true, presence: { message: 'cannot be generated' } @@ -31,6 +29,7 @@ class Key < ActiveRecord::Base after_destroy :post_destroy_hook def key=(value) + value&.delete!("\n\r") value.strip! unless value.blank? write_attribute(:key, value) end |