mirror of
https://github.com/internetee/registry.git
synced 2025-05-17 17:59:47 +02:00
Sanitize cert before saving #2687
This commit is contained in:
parent
e6387a2847
commit
0732f55d7c
2 changed files with 6 additions and 1 deletions
|
@ -15,7 +15,7 @@ class Admin::CertificatesController < AdminController
|
||||||
crt = certificate_params[:crt].open.read if certificate_params[:crt]
|
crt = certificate_params[:crt].open.read if certificate_params[:crt]
|
||||||
csr = certificate_params[:csr].open.read if certificate_params[:csr]
|
csr = certificate_params[:csr].open.read if certificate_params[:csr]
|
||||||
|
|
||||||
@certificate = @api_user.certificates.build(csr: csr, crt: crt)
|
@certificate = @api_user.certificates.build(csr: Certificate.sanitize(csr), crt: Certificate.sanitize(crt))
|
||||||
if @api_user.save
|
if @api_user.save
|
||||||
flash[:notice] = I18n.t('record_created')
|
flash[:notice] = I18n.t('record_created')
|
||||||
redirect_to [:admin, @api_user, @certificate]
|
redirect_to [:admin, @api_user, @certificate]
|
||||||
|
|
|
@ -132,6 +132,11 @@ class Certificate < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
class << self
|
class << self
|
||||||
|
def sanitize(c)
|
||||||
|
return nil unless c
|
||||||
|
c.gsub("\r", '')
|
||||||
|
end
|
||||||
|
|
||||||
def update_crl
|
def update_crl
|
||||||
update_id_crl
|
update_id_crl
|
||||||
update_registry_crl
|
update_registry_crl
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue