Story #108518226 - add IDN lookup method to support info and check features of EPP

This commit is contained in:
Matt Farnsworth 2015-11-19 19:11:30 +02:00
parent 360fb57a68
commit bbc53700bd
3 changed files with 13 additions and 2 deletions

View file

@ -225,7 +225,7 @@ class Epp::DomainsController < EppController
def find_domain def find_domain
domain_name = params[:parsed_frame].css('name').text.strip.downcase domain_name = params[:parsed_frame].css('name').text.strip.downcase
@domain = Epp::Domain.where(name: domain_name).includes(registrant: :registrar).first @domain = Epp::Domain.find_by_idn domain_name
unless @domain unless @domain
epp_errors << { epp_errors << {

View file

@ -334,6 +334,17 @@ class Domain < ActiveRecord::Base
self[:name_dirty] = value self[:name_dirty] = value
end end
# find by internationalized domain name
# internet domain name => ascii or puny, but db::domains.name is unicode
def self.find_by_idn(name)
domain = self.find_by_name name
if domain.blank? && name.include?('-')
unicode = SimpleIDN.to_unicode name # we have no index on domains.name_puny
domain = self.find_by_name unicode
end
domain
end
def roid def roid
"EIS-#{id}" "EIS-#{id}"
end end

View file

@ -850,7 +850,7 @@ class Epp::Domain < Domain
next next
end end
if Domain.find_by(name: x) if Domain.find_by_idn x
res << { name: x, avail: 0, reason: 'in use' } res << { name: x, avail: 0, reason: 'in use' }
else else
res << { name: x, avail: 1 } res << { name: x, avail: 1 }