mirror of
https://github.com/internetee/registry.git
synced 2025-06-11 07:04:47 +02:00
Use match? instead of match
for regex where MatchData is unused
This commit is contained in:
parent
db08ad7125
commit
82dbd3e8b8
7 changed files with 12 additions and 10 deletions
|
@ -29,7 +29,7 @@ module Repp
|
||||||
# example: curl -u registrar1:password localhost:3000/repp/v1/domains/1/transfer_info -H "Auth-Code: authinfopw1"
|
# example: curl -u registrar1:password localhost:3000/repp/v1/domains/1/transfer_info -H "Auth-Code: authinfopw1"
|
||||||
get '/:id/transfer_info', requirements: { id: /.*/ } do
|
get '/:id/transfer_info', requirements: { id: /.*/ } do
|
||||||
ident = params[:id]
|
ident = params[:id]
|
||||||
domain = ident =~ /\A[0-9]+\z/ ? Domain.find_by(id: ident) : Domain.find_by_idn(ident)
|
domain = ident.match?(/\A[0-9]+\z/) ? Domain.find_by(id: ident) : Domain.find_by_idn(ident)
|
||||||
|
|
||||||
error! I18n.t('errors.messages.epp_domain_not_found'), 404 unless domain
|
error! I18n.t('errors.messages.epp_domain_not_found'), 404 unless domain
|
||||||
error! I18n.t('errors.messages.epp_authorization_error'), 401 unless domain.transfer_code.eql? request.headers['Auth-Code']
|
error! I18n.t('errors.messages.epp_authorization_error'), 401 unless domain.transfer_code.eql? request.headers['Auth-Code']
|
||||||
|
|
|
@ -145,7 +145,7 @@ class EppController < ApplicationController
|
||||||
# VALIDATION
|
# VALIDATION
|
||||||
def latin_only
|
def latin_only
|
||||||
return true if params['frame'].blank?
|
return true if params['frame'].blank?
|
||||||
return true if params['frame'].match(/\A[\p{Latin}\p{Z}\p{P}\p{S}\p{Cc}\p{Cf}\w_\'\+\-\.\(\)\/]*\Z/i)
|
return true if params['frame'].match?(/\A[\p{Latin}\p{Z}\p{P}\p{S}\p{Cc}\p{Cf}\w_\'\+\-\.\(\)\/]*\Z/i)
|
||||||
|
|
||||||
epp_errors << {
|
epp_errors << {
|
||||||
msg: 'Parameter value policy error. Allowed only Latin characters.',
|
msg: 'Parameter value policy error. Allowed only Latin characters.',
|
||||||
|
|
|
@ -87,14 +87,14 @@ class Certificate < ActiveRecord::Base
|
||||||
-extensions usr_cert -notext -md sha256 \
|
-extensions usr_cert -notext -md sha256 \
|
||||||
-in #{csr_file.path} -out #{crt_file.path} -key '#{ENV['ca_key_password']}' -batch")
|
-in #{csr_file.path} -out #{crt_file.path} -key '#{ENV['ca_key_password']}' -batch")
|
||||||
|
|
||||||
if err.match(/Data Base Updated/)
|
if err.match?(/Data Base Updated/)
|
||||||
crt_file.rewind
|
crt_file.rewind
|
||||||
self.crt = crt_file.read
|
self.crt = crt_file.read
|
||||||
self.md5 = OpenSSL::Digest::MD5.new(parsed_crt.to_der).to_s
|
self.md5 = OpenSSL::Digest::MD5.new(parsed_crt.to_der).to_s
|
||||||
save!
|
save!
|
||||||
else
|
else
|
||||||
logger.error('FAILED TO CREATE CLIENT CERTIFICATE')
|
logger.error('FAILED TO CREATE CLIENT CERTIFICATE')
|
||||||
if err.match(/TXT_DB error number 2/)
|
if err.match?(/TXT_DB error number 2/)
|
||||||
errors.add(:base, I18n.t('failed_to_create_crt_csr_already_signed'))
|
errors.add(:base, I18n.t('failed_to_create_crt_csr_already_signed'))
|
||||||
logger.error('CSR ALREADY SIGNED')
|
logger.error('CSR ALREADY SIGNED')
|
||||||
else
|
else
|
||||||
|
|
|
@ -34,9 +34,9 @@ module Versions
|
||||||
end
|
end
|
||||||
|
|
||||||
def user_from_id_role_username(str)
|
def user_from_id_role_username(str)
|
||||||
user = ApiUser.find_by(id: $1) if str =~ /^(\d+)-(ApiUser:|api-)/
|
user = ApiUser.find_by(id: $1) if str.match(/^(\d+)-(ApiUser:|api-)/)
|
||||||
unless user.present?
|
unless user.present?
|
||||||
user = AdminUser.find_by(id: $1) if str =~ /^(\d+)-AdminUser:/
|
user = AdminUser.find_by(id: $1) if str.match(/^(\d+)-AdminUser:/)
|
||||||
unless user.present?
|
unless user.present?
|
||||||
# on import we copied Registrar name, which may eql code
|
# on import we copied Registrar name, which may eql code
|
||||||
registrar = Registrar.find_by(name: str)
|
registrar = Registrar.find_by(name: str)
|
||||||
|
|
|
@ -105,13 +105,13 @@ class Nameserver < ActiveRecord::Base
|
||||||
|
|
||||||
def validate_ipv4_format
|
def validate_ipv4_format
|
||||||
ipv4.to_a.each do |ip|
|
ipv4.to_a.each do |ip|
|
||||||
errors.add(:ipv4, :invalid) unless ip =~ IPV4_REGEXP
|
errors.add(:ipv4, :invalid) unless ip.match?(IPV4_REGEXP)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def validate_ipv6_format
|
def validate_ipv6_format
|
||||||
ipv6.to_a.each do |ip|
|
ipv6.to_a.each do |ip|
|
||||||
errors.add(:ipv6, :invalid) unless ip =~ IPV6_REGEXP
|
errors.add(:ipv6, :invalid) unless ip.match?(IPV6_REGEXP)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -10,7 +10,9 @@ class Contact::Ident::RegNoValidator < ActiveModel::EachValidator
|
||||||
|
|
||||||
return unless format
|
return unless format
|
||||||
|
|
||||||
record.errors.add(attribute, :invalid_reg_no, country: record.country) unless value =~ format
|
unless value.match?(format)
|
||||||
|
record.errors.add(attribute, :invalid_reg_no, country: record.country)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
|
@ -22,7 +22,7 @@ class DomainNameValidator < ActiveModel::EachValidator
|
||||||
# it's punycode
|
# it's punycode
|
||||||
if value[2] == '-' && value[3] == '-'
|
if value[2] == '-' && value[3] == '-'
|
||||||
regexp = /\Axn--[a-zA-Z0-9-]{0,59}\.#{general_domains}\z/
|
regexp = /\Axn--[a-zA-Z0-9-]{0,59}\.#{general_domains}\z/
|
||||||
return false unless value =~ regexp
|
return false unless value.match?(regexp)
|
||||||
value = SimpleIDN.to_unicode(value).mb_chars.downcase.strip
|
value = SimpleIDN.to_unicode(value).mb_chars.downcase.strip
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue