diff --git a/app/controllers/epp_controller.rb b/app/controllers/epp_controller.rb index 551f065a7..496526d71 100644 --- a/app/controllers/epp_controller.rb +++ b/app/controllers/epp_controller.rb @@ -145,7 +145,9 @@ class EppController < ApplicationController # VALIDATION def latin_only 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) + if params['frame'].match?(/\A[\p{Latin}\p{Z}\p{P}\p{S}\p{Cc}\p{Cf}\w_\'\+\-\.\(\)\/]*\Z/i) + return true + end epp_errors << { msg: 'Parameter value policy error. Allowed only Latin characters.', diff --git a/app/models/concerns/versions.rb b/app/models/concerns/versions.rb index 5a0ad5705..91926272c 100644 --- a/app/models/concerns/versions.rb +++ b/app/models/concerns/versions.rb @@ -34,9 +34,13 @@ module Versions end def user_from_id_role_username(str) - user = ApiUser.find_by(id: $1) if str.match(/^(\d+)-(ApiUser:|api-)/) + if str.match(/^(\d+)-(ApiUser:|api-)/) + user = ApiUser.find_by(id: $1) + end unless user.present? - user = AdminUser.find_by(id: $1) if str.match(/^(\d+)-AdminUser:/) + user = if str.match(/^(\d+)-AdminUser:/) + AdminUser.find_by(id: $1) + end unless user.present? # on import we copied Registrar name, which may eql code registrar = Registrar.find_by(name: str) diff --git a/app/models/nameserver.rb b/app/models/nameserver.rb index 85792f5da..d9fdde406 100644 --- a/app/models/nameserver.rb +++ b/app/models/nameserver.rb @@ -100,7 +100,7 @@ class Nameserver < ActiveRecord::Base def check_puny_symbols regexp = /(\A|\.)..--/ - errors.add(:hostname, :invalid) if hostname =~ regexp + errors.add(:hostname, :invalid) if hostname.match?(regexp) end def validate_ipv4_format diff --git a/app/validators/contact/ident/reg_no_validator.rb b/app/validators/contact/ident/reg_no_validator.rb index 9d829a50b..138aab56a 100644 --- a/app/validators/contact/ident/reg_no_validator.rb +++ b/app/validators/contact/ident/reg_no_validator.rb @@ -10,9 +10,8 @@ class Contact::Ident::RegNoValidator < ActiveModel::EachValidator return unless format - unless value.match?(format) - record.errors.add(attribute, :invalid_reg_no, country: record.country) - end + return if value.match?(format) + record.errors.add(attribute, :invalid_reg_no, country: record.country) end private