From bbc53700bd99667be201666c954f265cd1a34609 Mon Sep 17 00:00:00 2001 From: Matt Farnsworth Date: Thu, 19 Nov 2015 19:11:30 +0200 Subject: [PATCH] Story #108518226 - add IDN lookup method to support info and check features of EPP --- app/controllers/epp/domains_controller.rb | 2 +- app/models/domain.rb | 11 +++++++++++ app/models/epp/domain.rb | 2 +- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/app/controllers/epp/domains_controller.rb b/app/controllers/epp/domains_controller.rb index 8426c8ccb..74ad6ae63 100644 --- a/app/controllers/epp/domains_controller.rb +++ b/app/controllers/epp/domains_controller.rb @@ -225,7 +225,7 @@ class Epp::DomainsController < EppController def find_domain 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 epp_errors << { diff --git a/app/models/domain.rb b/app/models/domain.rb index 9845e8ac8..b8b7d55aa 100644 --- a/app/models/domain.rb +++ b/app/models/domain.rb @@ -334,6 +334,17 @@ class Domain < ActiveRecord::Base self[:name_dirty] = value 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 "EIS-#{id}" end diff --git a/app/models/epp/domain.rb b/app/models/epp/domain.rb index ffd525d9d..51601bd51 100644 --- a/app/models/epp/domain.rb +++ b/app/models/epp/domain.rb @@ -850,7 +850,7 @@ class Epp::Domain < Domain next end - if Domain.find_by(name: x) + if Domain.find_by_idn x res << { name: x, avail: 0, reason: 'in use' } else res << { name: x, avail: 1 }