Permalink
Browse files

Fix issue with whois.tucows.com when the response contains a malforme…

…d phone
  • Loading branch information...
1 parent 2fb5441 commit 4673715ecd139b1c65a6182fa32c74849954bbd8 @weppos committed Aug 13, 2012
@@ -84,7 +84,8 @@ class WhoisTucowsCom < Base
private
def build_contact(element, type)
- match = content_for_scanner.slice(/#{element}.*\n((.*\n){5})/, 1)
+ indent = type == Record::Contact::TYPE_REGISTRANT ? 1 : 4
+ match = content_for_scanner.slice(/#{element}.*\n((#{' ' * indent}.+\n)+)/, 1)
return unless match
# 0 Almahdi, Ahmad alatol@yahoo.com
@@ -102,7 +103,7 @@ def build_contact(element, type)
items.delete_at(0).strip
end
- phone, fax = if items[-1] =~ /^\s+\+/
+ phone, fax = if items[-1] =~ /^\s+\+?\d+/
items.delete_at(-1).match(/\s+(.+?)\s*(?:Fax: (.+))?$/).to_a[1,2]
end
@@ -0,0 +1,31 @@
+#admin_contacts
+ should: %s CLASS(array)
+ should: %s SIZE(1)
+ should: %s[0] CLASS(contact)
+ should: %s[0].type == Whois::Record::Contact::TYPE_ADMIN
+ should: %s[0].name == "Thomas, Jennifer"
+ should: %s[0].organization == nil
+ should: %s[0].address == "594 E. Millsap"
+ should: %s[0].city == "Fayetteville"
+ should: %s[0].zip == "72703"
+ should: %s[0].state == "AR"
+ should: %s[0].country_code == "US"
+ should: %s[0].phone == "479-442-2020"
+ should: %s[0].fax == nil
+ should: %s[0].email == "jthomas@see2020now.net"
+
+#technical_contacts
+ should: %s CLASS(array)
+ should: %s SIZE(1)
+ should: %s[0] CLASS(contact)
+ should: %s[0].type == Whois::Record::Contact::TYPE_TECHNICAL
+ should: %s[0].name == "Hostmaster, Contact"
+ should: %s[0].organization == nil
+ should: %s[0].address == "101 W. Mountain St.\nSuite 101"
+ should: %s[0].city == "Fayetteville"
+ should: %s[0].zip == "72701"
+ should: %s[0].state == "AR"
+ should: %s[0].country_code == "US"
+ should: %s[0].phone == "479-521-3100"
+ should: %s[0].fax == "479-521-3188"
+ should: %s[0].email == "hostmaster@gcmcomputers.com"
@@ -0,0 +1,83 @@
+Registrant:
+ The Eye Center
+ 594 E. Millsap
+ Fayetteville, AR 72703
+ US
+
+ Domain name: SEE2020NOW.COM
+
+
+ Administrative Contact:
+ Thomas, Jennifer jthomas@see2020now.net
+ 594 E. Millsap
+ Fayetteville, AR 72703
+ US
+ 479-442-2020
+ Technical Contact:
+ Hostmaster, Contact hostmaster@gcmcomputers.com
+ 101 W. Mountain St.
+ Suite 101
+ Fayetteville, AR 72701
+ US
+ 479-521-3100 Fax: 479-521-3188
+
+
+
+ Registration Service Provider:
+ GCM Computers, Inc., hostmaster@gcmcomputers.com
+ 479-521-3100
+ 479-521-3188 (fax)
+ http://www.gcmcomputers.com
+
+
+
+ Registrar of Record: TUCOWS, INC.
+ Record last updated on 09-Nov-2011.
+ Record expires on 06-Feb-2014.
+ Record created on 06-Feb-2002.
+
+ Registrar Domain Name Help Center:
+ http://tucowsdomains.com
+
+ Domain servers in listed order:
+ NS2.GCMCOMPUTERS.COM
+ NS3.GCMCOMPUTERS.COM
+ NS1.GCMCOMPUTERS.COM
+
+
+ Domain status: clientTransferProhibited
+ clientUpdateProhibited
+
+The Data in the Tucows Registrar WHOIS database is provided to you by Tucows
+for information purposes only, and may be used to assist you in obtaining
+information about or related to a domain name's registration record.
+
+Tucows makes this information available "as is," and does not guarantee its
+accuracy.
+
+By submitting a WHOIS query, you agree that you will use this data only for
+lawful purposes and that, under no circumstances will you use this data to:
+a) allow, enable, or otherwise support the transmission by e-mail,
+telephone, or facsimile of mass, unsolicited, commercial advertising or
+solicitations to entities other than the data recipient's own existing
+customers; or (b) enable high volume, automated, electronic processes that
+send queries or data to the systems of any Registry Operator or
+ICANN-Accredited registrar, except as reasonably necessary to register
+domain names or modify existing registrations.
+
+The compilation, repackaging, dissemination or other use of this Data is
+expressly prohibited without the prior written consent of Tucows.
+
+Tucows reserves the right to terminate your access to the Tucows WHOIS
+database in its sole discretion, including without limitation, for excessive
+querying of the WHOIS database or for failure to otherwise abide by this
+policy.
+
+Tucows reserves the right to modify these terms at any time.
+
+By submitting this query, you agree to abide by these terms.
+
+NOTE: THE WHOIS DATABASE IS A CONTACT DATABASE ONLY. LACK OF A DOMAIN
+RECORD DOES NOT SIGNIFY DOMAIN AVAILABILITY.
+
+
@@ -0,0 +1,60 @@
+# encoding: utf-8
+
+# This file is autogenerated. Do not edit it manually.
+# If you want change the content of this file, edit
+#
+# /spec/fixtures/responses/whois.tucows.com/property_contacts_4.expected
+#
+# and regenerate the tests with the following rake task
+#
+# $ rake spec:generate
+#
+
+require 'spec_helper'
+require 'whois/record/parser/whois.tucows.com.rb'
+
+describe Whois::Record::Parser::WhoisTucowsCom, "property_contacts_4.expected" do
+
+ before(:each) do
+ file = fixture("responses", "whois.tucows.com/property_contacts_4.txt")
+ part = Whois::Record::Part.new(:body => File.read(file))
+ @parser = klass.new(part)
+ end
+
+ describe "#admin_contacts" do
+ it do
+ @parser.admin_contacts.should be_a(Array)
+ @parser.admin_contacts.should have(1).items
+ @parser.admin_contacts[0].should be_a(Whois::Record::Contact)
+ @parser.admin_contacts[0].type.should == Whois::Record::Contact::TYPE_ADMIN
+ @parser.admin_contacts[0].name.should == "Thomas, Jennifer"
+ @parser.admin_contacts[0].organization.should == nil
+ @parser.admin_contacts[0].address.should == "594 E. Millsap"
+ @parser.admin_contacts[0].city.should == "Fayetteville"
+ @parser.admin_contacts[0].zip.should == "72703"
+ @parser.admin_contacts[0].state.should == "AR"
+ @parser.admin_contacts[0].country_code.should == "US"
+ @parser.admin_contacts[0].phone.should == "479-442-2020"
+ @parser.admin_contacts[0].fax.should == nil
+ @parser.admin_contacts[0].email.should == "jthomas@see2020now.net"
+ end
+ end
+ describe "#technical_contacts" do
+ it do
+ @parser.technical_contacts.should be_a(Array)
+ @parser.technical_contacts.should have(1).items
+ @parser.technical_contacts[0].should be_a(Whois::Record::Contact)
+ @parser.technical_contacts[0].type.should == Whois::Record::Contact::TYPE_TECHNICAL
+ @parser.technical_contacts[0].name.should == "Hostmaster, Contact"
+ @parser.technical_contacts[0].organization.should == nil
+ @parser.technical_contacts[0].address.should == "101 W. Mountain St.\nSuite 101"
+ @parser.technical_contacts[0].city.should == "Fayetteville"
+ @parser.technical_contacts[0].zip.should == "72701"
+ @parser.technical_contacts[0].state.should == "AR"
+ @parser.technical_contacts[0].country_code.should == "US"
+ @parser.technical_contacts[0].phone.should == "479-521-3100"
+ @parser.technical_contacts[0].fax.should == "479-521-3188"
+ @parser.technical_contacts[0].email.should == "hostmaster@gcmcomputers.com"
+ end
+ end
+end

0 comments on commit 4673715

Please sign in to comment.