Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fixed parsing of nameservers on register.com #207

Merged
merged 1 commit into from

2 participants

@stormsilver

When there were four nameservers listed, followed by a "blank" nameserver,
the parser would mistakenly include the blank line and the dates following it.

@stormsilver stormsilver Fixed parsing of nameservers on register.com
When there were four nameservers listed, followed by a "blank" nameserver,
the parser would mistakenly include the blank line and the dates following it.
7db1a90
@weppos
Owner

Excellent patch, thank you @stormsilver

@weppos weppos merged commit 405bbd0 into weppos:master
@weppos weppos was assigned
@weppos
Owner

@stormsilver I merged the patch, however I noticed that the fixture was including both Verisign and Register response. Also, I can't find a blank nameserver in the fixture.

I tried to download it from the bar.com response, but it was different. The domain seems to be registered with GoDaddy. Did you "created" it?

I'll revert the patch for now. Let me know.

@weppos weppos referenced this pull request from a commit
@weppos Update CHANGELOG for GH-207 bc78f1a
@stormsilver

Hi @weppos, yes, I just inserted "bar.com" into the fixture to anonymize it a little bit - didn't want to check in real data. I generated the fixture by running File.open('/tmp/foo.txt', 'w') {|f| f.puts Whois.query('54ustore.com')}, so the fixture should be 100% real, other than the data that I anonymized. Whois was definitely failing on that domain, which is why I even looked into the issue in the first place. Let me know if I can do anything else to help.

@weppos
Owner

@stormsilver thank you, I was able to reproduce the issue. It should be fixed now with 833824e

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 20, 2013
  1. @stormsilver

    Fixed parsing of nameservers on register.com

    stormsilver authored
    When there were four nameservers listed, followed by a "blank" nameserver,
    the parser would mistakenly include the blank line and the dates following it.
This page is out of date. Refresh to see the latest.
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
Something went wrong with that request. Please try again.