Permalink
Browse files

Fix whois.enom.com parser crash with long address

  • Loading branch information...
1 parent bd89791 commit b90d99ea626f1db993b361f0fe5a364785d945e0 @weppos committed Mar 28, 2012
@@ -95,21 +95,22 @@ def build_contact(element, type)
# 4 731 Market Street, Suite 500
# 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]
- city, state, zip = lines[5].match(/(.+), (.+?) (\d+)/)[1..3]
+ fax = lines[3].match(/Fax:(.*)/)[1].strip
+ city, state, zip = lines[-2].match(/(.+), (.+?) (\d+)/)[1..3]
Record::Contact.new(
:type => type,
:id => nil,
:name => name,
:organization => lines[0],
- :address => lines[4],
+ :address => lines[4..-3].join("\n"),
:city => city,
:zip => zip,
:state => state,
- :country_code => lines[6],
+ :country_code => lines[-1],
:phone => lines[2],
:fax => fax,
:email => email
@@ -0,0 +1,15 @@
+#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 == "Matt Barrie"
+ should: %s[0].organization == "Freelancer Technology Pty Limited"
+ should: %s[0].address == "Suite 501\n35 Lime Street"
+ should: %s[0].city == "Sydney"
+ should: %s[0].zip == "2000"
+ should: %s[0].state == "NSW"
+ should: %s[0].country_code == "AU"
+ should: %s[0].phone == "+61.292793305"
+ should: %s[0].fax == "+61.292793305"
+ should: %s[0].email == "noc@freelancer.com"
@@ -0,0 +1,67 @@
+=-=-=-=
+Visit AboutUs.org for more information about freelancer.com
+<a href="http://www.aboutus.org/freelancer.com">AboutUs: freelancer.com</a>
+
+
+Domain name: freelancer.com
+
+Registrant Contact:
+ Freelancer Technology Pty Limited
+ Matt Barrie ()
+
+ Fax:
+ Suite 501
+ 35 Lime Street
+ Sydney, NSW 2000
+ AU
+
+Administrative Contact:
+ Freelancer Australia Pty Limited
+ Customer Service (customer-support@freelancer.com)
+ +61.292793305
+ Fax: +61.292793305
+ Suite 501
+ 35 Lime Street
+ Sydney, NSW 2000
+ AU
+
+Technical Contact:
+ Freelancer Technology Pty Limited
+ Matt Barrie (noc@freelancer.com)
+ +61.292793305
+ Fax: +61.292793305
+ Suite 501
+ 35 Lime Street
+ Sydney, NSW 2000
+ AU
+
+Status: Locked
+
+Name Servers:
+ DNS1.GETAFREELANCER.COM
+ DNS2.GETAFREELANCER.COM
+
+Creation date: 18 Aug 1995 04:00:00
+Expiration date: 17 Aug 2015 04:00: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
@@ -0,0 +1,42 @@
+# 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_contact_long_address.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_contact_long_address.expected" do
+
+ before(:each) do
+ file = fixture("responses", "whois.enom.com/property_contact_long_address.txt")
+ part = Whois::Record::Part.new(:body => File.read(file))
+ @parser = klass.new(part)
+ 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 == "Matt Barrie"
+ @parser.technical_contacts[0].organization.should == "Freelancer Technology Pty Limited"
+ @parser.technical_contacts[0].address.should == "Suite 501\n35 Lime Street"
+ @parser.technical_contacts[0].city.should == "Sydney"
+ @parser.technical_contacts[0].zip.should == "2000"
+ @parser.technical_contacts[0].state.should == "NSW"
+ @parser.technical_contacts[0].country_code.should == "AU"
+ @parser.technical_contacts[0].phone.should == "+61.292793305"
+ @parser.technical_contacts[0].fax.should == "+61.292793305"
+ @parser.technical_contacts[0].email.should == "noc@freelancer.com"
+ end
+ end
+end

0 comments on commit b90d99e

Please sign in to comment.