Permalink
Browse files

Merge pull request #207 from stormsilver/fix-registercom

Fixed parsing of nameservers on register.com
  • Loading branch information...
2 parents c1753f1 + 7db1a90 commit 405bbd0b49fa8e0f34a3fb8257c981305e7619e1 @weppos committed Feb 22, 2013
View
6 lib/whois/record/parser/whois.register.com.rb
@@ -71,8 +71,10 @@ class WhoisRegisterCom < Base
property_supported :nameservers do
if content_for_scanner =~ /(?:DNS|Name) Servers:\n((.+\n)+)\n/
$1.split("\n").map do |line|
- Record::Nameserver.new(:name => line.strip)
- end
+ stripped = line.strip
+ next if stripped.empty? || !line.start_with?(' ')
+ Record::Nameserver.new(:name => stripped)
+ end.compact
end
end
View
11 spec/fixtures/responses/whois.register.com/four_nameservers.expected
@@ -0,0 +1,11 @@
+#nameservers
+ should: %s CLASS(array)
+ should: %s SIZE(4)
+ should: %s[0] CLASS(nameserver)
+ should: %s[0].name == "ns-1.foo.com"
+ should: %s[1] CLASS(nameserver)
+ should: %s[1].name == "ns-2.foo.org"
+ should: %s[2] CLASS(nameserver)
+ should: %s[2].name == "ns-3.foo.co.uk"
+ should: %s[3] CLASS(nameserver)
+ should: %s[3].name == "ns-4.foo.net"
View
145 spec/fixtures/responses/whois.register.com/four_nameservers.txt
@@ -0,0 +1,145 @@
+
+Whois Server Version 2.0
+
+Domain names in the .com and .net domains can now be registered
+with many different competing registrars. Go to http://www.internic.net
+for detailed information.
+
+ Domain Name: BAR.COM
+ Registrar: REGISTER.COM, INC.
+ Whois Server: whois.register.com
+ Referral URL: http://www.register.com
+ Name Server: NS-1.FOO.COM
+ Name Server: NS-2.FOO.ORG
+ Name Server: NS-3.FOO.CO.UK
+ Name Server: NS-4.FOO.NET
+ Status: ok
+ Updated Date: 23-jan-2013
+ Creation Date: 23-dec-2002
+ Expiration Date: 23-dec-2013
+
+>>> Last update of whois database: Wed, 20 Feb 2013 19:50:59 UTC <<<
+
+NOTICE: The expiration date displayed in this record is the date the
+registrar's sponsorship of the domain name registration in the registry is
+currently set to expire. This date does not necessarily reflect the expiration
+date of the domain name registrant's agreement with the sponsoring
+registrar. Users may consult the sponsoring registrar's Whois database to
+view the registrar's reported date of expiration for this registration.
+
+TERMS OF USE: You are not authorized to access or query our Whois
+database through the use of electronic processes that are high-volume and
+automated except as reasonably necessary to register domain names or
+modify existing registrations; the Data in VeriSign Global Registry
+Services' ("VeriSign") Whois database is provided by VeriSign for
+information purposes only, and to assist persons in obtaining information
+about or related to a domain name registration record. VeriSign does not
+guarantee its accuracy. By submitting a Whois query, you agree to abide
+by the following terms of use: You agree that you may use this Data only
+for lawful purposes and that under no circumstances will you use this Data
+to: (1) allow, enable, or otherwise support the transmission of mass
+unsolicited, commercial advertising or solicitations via e-mail, telephone,
+or facsimile; or (2) enable high volume, automated, electronic processes
+that apply to VeriSign (or its computer systems). The compilation,
+repackaging, dissemination or other use of this Data is expressly
+prohibited without the prior written consent of VeriSign. You agree not to
+use electronic processes that are automated and high-volume to access or
+query the Whois database except as reasonably necessary to register
+domain names or modify existing registrations. VeriSign reserves the right
+to restrict your access to the Whois database in its sole discretion to ensure
+operational stability. VeriSign may restrict or terminate your access to the
+Whois database for failure to abide by these terms of use. VeriSign
+reserves the right to modify these terms at any time.
+
+The Registry database contains ONLY .COM, .NET, .EDU domains and
+Registrars.
+
+The data in Register.com's WHOIS database is provided to you by
+Register.com for information purposes only, that is, to assist you in
+obtaining information about or related to a domain name registration
+record. Register.com 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: (1) allow, enable,
+or otherwise support the transmission of mass unsolicited, commercial
+advertising or solicitations via direct mail, electronic mail, or by
+telephone; or (2) enable high volume, automated, electronic processes
+that apply to Register.com (or its systems). The compilation,
+repackaging, dissemination or other use of this data is expressly
+prohibited without the prior written consent of Register.com.
+Register.com reserves the right to modify these terms at any time.
+By submitting this query, you agree to abide by these terms.
+
+
+=-=-=-=
+
+
+Domain name: bar.com
+ Is the domain you want taken? Make an offer: http://www.afternic.com/rcom.php?ref_id=1234&name=bar.com
+
+Administrative Contact:
+ John Smith, Inc.
+ John Smith (jsmith@bar.com)
+ +1.1112223333
+ Fax: .
+ 123 Main St
+ Anytown, ST 11111
+ US
+
+Technical Contact:
+ John Smith, Inc.
+ John Smith (jsmith@bar.com)
+ +1.1112223333
+ Fax: .
+ 123 Main St
+ Anytown, ST 11111
+ US
+
+Registrant Contact:
+ John Smith, Inc.
+ John Smith ()
+
+ Fax:
+ 123 Main St
+ Anytown, ST 11111
+ US
+
+Status: Locked
+
+Name Servers:
+ ns-1.foo.com
+ ns-2.foo.org
+ ns-3.foo.co.uk
+ ns-4.foo.net
+
+Creation date: 23 Dec 2002 19:56:11
+Expiration date: 23 Dec 2013 19:56:11
+
+
+
+
+=-=-=-=
+The data in this whois database is provided to you for information
+purposes only, that is, to assist you in obtaining information about or
+related to a domain name registration record. We make this information
+available "as is," and do 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: (1)
+enable high volume, automated, electronic processes that stress or load
+this whois database system providing you this information; or (2) allow,
+enable, or otherwise support the transmission of mass unsolicited,
+commercial advertising or solicitations via direct mail, electronic
+mail, or by telephone. The compilation, repackaging, dissemination or
+other use of this data is expressly prohibited without prior written
+consent from us.
+
+We reserve the right to modify these terms at any time. By submitting
+this query, you agree to abide by these terms.
+Version 6.3 4/3/2002
+
+
+Visit AboutUs.org for more information about bar.com
+
+<A HREF="http://www.aboutus.org/bar.com">AboutUs: bar.com</A>
+
+Register your domain name at http://www.register.com
View
38 spec/whois/record/parser/responses/whois.register.com/four_nameservers_spec.rb
@@ -0,0 +1,38 @@
+# 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.register.com/four_nameservers.expected
+#
+# and regenerate the tests with the following rake task
+#
+# $ rake spec:generate
+#
+
+require 'spec_helper'
+require 'whois/record/parser/whois.register.com.rb'
+
+describe Whois::Record::Parser::WhoisRegisterCom, "four_nameservers.expected" do
+
+ subject do
+ file = fixture("responses", "whois.register.com/four_nameservers.txt")
+ part = Whois::Record::Part.new(:body => File.read(file))
+ described_class.new(part)
+ end
+
+ describe "#nameservers" do
+ it do
+ subject.nameservers.should be_a(Array)
+ subject.nameservers.should have(4).items
+ subject.nameservers[0].should be_a(Whois::Record::Nameserver)
+ subject.nameservers[0].name.should == "ns-1.foo.com"
+ subject.nameservers[1].should be_a(Whois::Record::Nameserver)
+ subject.nameservers[1].name.should == "ns-2.foo.org"
+ subject.nameservers[2].should be_a(Whois::Record::Nameserver)
+ subject.nameservers[2].name.should == "ns-3.foo.co.uk"
+ subject.nameservers[3].should be_a(Whois::Record::Nameserver)
+ subject.nameservers[3].name.should == "ns-4.foo.net"
+ end
+ end
+end

0 comments on commit 405bbd0

Please sign in to comment.