Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix whois.enom.com parser crash when contact is almost empty

  • Loading branch information...
commit e0fec470892ad35c795cb70720dc401895418059 1 parent 0e000d1
@weppos authored
View
8 lib/whois/record/parser/whois.enom.com.rb
@@ -96,10 +96,10 @@ def build_contact(element, type)
# 5 San Francisco, CA 94103
# 6 US
- lines = match.split("\n").map(&:strip)
- name, email = lines[1].match(/(.+) \((.*)\)/)[1..2]
- fax = lines[3].match(/Fax:(.*)/)[1].strip
- city, state, zip = lines[-2].match(/(.+), (.+?) (\d+)/)[1..3]
+ lines = match.split("\n").map(&:lstrip)
+ name, email = lines[1].match(/(.+) \((.*)\)/)[1..2].map(&:strip)
+ fax = lines[3].match(/Fax: (.*)/)[1]
+ city, state, zip = lines[-2].match(/(.*),(.+?)(\d*)$/)[1..3].map(&:strip)
Record::Contact.new(
:type => type,
View
31 spec/fixtures/responses/whois.enom.com/property_contacts_almost_empty.expected
@@ -0,0 +1,31 @@
+#registrant_contacts
+ should: %s CLASS(array)
+ should: %s SIZE(1)
+ should: %s[0] CLASS(contact)
+ should: %s[0].type == Whois::Record::Contact::TYPE_REGISTRANT
+ should: %s[0].name == "Tony Kerr"
+ should: %s[0].organization == ""
+ should: %s[0].address == ""
+ should: %s[0].city == ""
+ should: %s[0].zip == ""
+ should: %s[0].state == ""
+ should: %s[0].country_code == "US"
+ should: %s[0].phone == ""
+ should: %s[0].fax == ""
+ should: %s[0].email == ""
+
+#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 == "Tony Kerr"
+ should: %s[0].organization == ""
+ should: %s[0].address == ""
+ should: %s[0].city == ""
+ should: %s[0].zip == ""
+ should: %s[0].state == ""
+ should: %s[0].country_code == "US"
+ should: %s[0].phone == "+1."
+ should: %s[0].fax == ""
+ should: %s[0].email == "tkerr@sportimeny.com"
View
61 spec/fixtures/responses/whois.enom.com/property_contacts_almost_empty.txt
@@ -0,0 +1,61 @@
+=-=-=-=
+Visit AboutUs.org for more information about johnmcenroetennisacademy.com
+<a href="http://www.aboutus.org/johnmcenroetennisacademy.com">AboutUs: johnmcenroetennisacademy.com</a>
+
+
+Domain name: johnmcenroetennisacademy.com
+
+Registrant Contact:
+
+ Tony Kerr ()
+
+ Fax:
+ ,
+ US
+
+Administrative Contact:
+
+ Tony Kerr (tkerr@sportimeny.com)
+ +1.
+ Fax:
+ ,
+ US
+
+Technical Contact:
+
+ Tony Kerr (tkerr@sportimeny.com)
+ +1.
+ Fax:
+ ,
+ US
+
+Status: Locked
+
+Name Servers:
+ ns1.saturn5.net
+ ns2.saturn5.net
+
+Creation date: 29 Apr 2010 17:18:00
+Expiration date: 29 Apr 2020 12:18:00
+
+
+
+Get Noticed on the Internet! Increase visibility for this domain name by listing it at www.whoisbusinesslistings.com
+=-=-=-=
+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
View
60 spec/whois/record/parser/responses/whois.enom.com/property_contacts_almost_empty_spec.rb
@@ -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.enom.com/property_contacts_almost_empty.expected
+#
+# and regenerate the tests with the following rake task
+#
+# $ rake spec:generate
+#
+
+require 'spec_helper'
+require 'whois/record/parser/whois.enom.com.rb'
+
+describe Whois::Record::Parser::WhoisEnomCom, "property_contacts_almost_empty.expected" do
+
+ before(:each) do
+ file = fixture("responses", "whois.enom.com/property_contacts_almost_empty.txt")
+ part = Whois::Record::Part.new(:body => File.read(file))
+ @parser = klass.new(part)
+ end
+
+ describe "#registrant_contacts" do
+ it do
+ @parser.registrant_contacts.should be_a(Array)
+ @parser.registrant_contacts.should have(1).items
+ @parser.registrant_contacts[0].should be_a(Whois::Record::Contact)
+ @parser.registrant_contacts[0].type.should == Whois::Record::Contact::TYPE_REGISTRANT
+ @parser.registrant_contacts[0].name.should == "Tony Kerr"
+ @parser.registrant_contacts[0].organization.should == ""
+ @parser.registrant_contacts[0].address.should == ""
+ @parser.registrant_contacts[0].city.should == ""
+ @parser.registrant_contacts[0].zip.should == ""
+ @parser.registrant_contacts[0].state.should == ""
+ @parser.registrant_contacts[0].country_code.should == "US"
+ @parser.registrant_contacts[0].phone.should == ""
+ @parser.registrant_contacts[0].fax.should == ""
+ @parser.registrant_contacts[0].email.should == ""
+ 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 == "Tony Kerr"
+ @parser.technical_contacts[0].organization.should == ""
+ @parser.technical_contacts[0].address.should == ""
+ @parser.technical_contacts[0].city.should == ""
+ @parser.technical_contacts[0].zip.should == ""
+ @parser.technical_contacts[0].state.should == ""
+ @parser.technical_contacts[0].country_code.should == "US"
+ @parser.technical_contacts[0].phone.should == "+1."
+ @parser.technical_contacts[0].fax.should == ""
+ @parser.technical_contacts[0].email.should == "tkerr@sportimeny.com"
+ end
+ end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.