Skip to content
This repository
Browse code

whois.nic.uk fails to parse registrars without URL (closes GH-188)

  • Loading branch information...
commit 5eb2e30dec2e794585511413e502e80cc164c601 1 parent 3098367
Simone Carletti authored
2  CHANGELOG.md
Source Rendered
@@ -9,6 +9,8 @@
9 9
10 10 * FIXED: whois.domainregistry.ie should support status `Active - LOCKED`.
11 11
  12 +* FIXED: whois.nic.uk fails to parse registrars without URL (GH-188).
  13 +
12 14
13 15 ## Release 2.7.0
14 16
36 lib/whois/record/parser/whois.nic.uk.rb
@@ -14,16 +14,11 @@ module Whois
14 14 class Record
15 15 class Parser
16 16
17   - #
18   - # = whois.nic.uk parser
19   - #
20 17 # Parser for the whois.nic.uk server.
21 18 #
22   - # NOTE: This parser is just a stub and provides only a few basic methods
23   - # to check for domain availability and get domain status.
24   - # Please consider to contribute implementing missing methods.
25   - # See WhoisNicIt parser for an explanation of all available methods
26   - # and examples.
  19 + # @note This parser is just a stub and provides only a few basic methods
  20 + # to check for domain availability and get domain status.
  21 + # Please consider to contribute implementing missing methods.
27 22 #
28 23 # @see http://www.nominet.org.uk/other/whois/detailedinstruct/
29 24 #
@@ -88,23 +83,26 @@ class WhoisNicUk < Base
88 83
89 84 # @see http://www.nic.uk/other/whois/instruct/
90 85 property_supported :registrar do
91   - if content_for_scanner =~ /Registrar:\n(.+) \[Tag = (.+)\]\n\s*URL: (.+)\n/
92   - name, id, url = $1.strip, $2.strip, $3.strip
93   - org, name = name.split(" t/a ")
  86 + if content_for_scanner =~ /Registrar:\n((.+\n)+)\n/
  87 + content = $1.strip
  88 + id = name = org = url = nil
  89 +
  90 + if content =~ /Tag =/
  91 + name, id = (content =~ /(.+) \[Tag = (.+)\]/) && [$1.strip, $2.strip]
  92 + org, name = name.split(" t/a ")
  93 + url = (content =~ /URL: (.+)/) && $1.strip
  94 + elsif content =~ /This domain is registered directly with Nominet/
  95 + name = "Nominet"
  96 + org = "Nominet UK"
  97 + url = "http://www.nic.uk/"
  98 + end
94 99
95 100 Record::Registrar.new(
96 101 :id => id,
97   - :name => (name || org),
  102 + :name => name || org,
98 103 :organization => org,
99 104 :url => url
100 105 )
101   - elsif content_for_scanner =~ /This domain is registered directly with Nominet/
102   - Record::Registrar.new(
103   - :id => nil,
104   - :name => "Nominet",
105   - :organization => "Nominet UK",
106   - :url => "http://www.nic.uk/"
107   - )
108 106 end
109 107 end
110 108
6 spec/fixtures/responses/whois.nic.uk/property_registrar_godaddy.expected
... ... @@ -0,0 +1,6 @@
  1 +#registrar
  2 + should: %s CLASS(registrar)
  3 + should: %s.id == "GODADDY"
  4 + should: %s.name == "GoDaddy.com, LLP."
  5 + should: %s.name == "GoDaddy.com, LLP."
  6 + should: %s.url == nil
47 spec/fixtures/responses/whois.nic.uk/property_registrar_godaddy.txt
... ... @@ -0,0 +1,47 @@
  1 +
  2 + Domain name:
  3 + ecigsbrand.co.uk
  4 +
  5 + Registrant:
  6 + Vitality & Wellness Ltd.
  7 +
  8 + Registrant type:
  9 + Unknown
  10 +
  11 + Registrant's address:
  12 + 72 High Street
  13 + Haslemere
  14 + Surrey
  15 + GU27 2LA
  16 + United Kingdom
  17 +
  18 + Registrar:
  19 + GoDaddy.com, LLP. [Tag = GODADDY]
  20 +
  21 + Relevant dates:
  22 + Registered on: 16-Sep-2010
  23 + Expiry date: 16-Sep-2013
  24 + Last updated: 30-Aug-2012
  25 +
  26 + Registration status:
  27 + Registered until expiry date.
  28 +
  29 + Name servers:
  30 + pdns01.domaincontrol.com
  31 + pdns02.domaincontrol.com
  32 +
  33 + WHOIS lookup made at 13:23:18 01-Oct-2012
  34 +
  35 +--
  36 +This WHOIS information is provided for free by Nominet UK the central registry
  37 +for .uk domain names. This information and the .uk WHOIS are:
  38 +
  39 + Copyright Nominet UK 1996 - 2012.
  40 +
  41 +You may not access the .uk WHOIS or use any data from it except as permitted
  42 +by the terms of use available in full at http://www.nominet.org.uk/whois, which
  43 +includes restrictions on: (A) use of the data for advertising, or its
  44 +repackaging, recompilation, redistribution or reuse (B) obscuring, removing
  45 +or hiding any or all of this notice and (C) exceeding query rate or volume
  46 +limits. The data is provided on an 'as-is' basis and may lag behind the
  47 +register. Access may be withdrawn or restricted at any time.
33 spec/whois/record/parser/responses/whois.nic.uk/property_registrar_godaddy_spec.rb
... ... @@ -0,0 +1,33 @@
  1 +# encoding: utf-8
  2 +
  3 +# This file is autogenerated. Do not edit it manually.
  4 +# If you want change the content of this file, edit
  5 +#
  6 +# /spec/fixtures/responses/whois.nic.uk/property_registrar_godaddy.expected
  7 +#
  8 +# and regenerate the tests with the following rake task
  9 +#
  10 +# $ rake spec:generate
  11 +#
  12 +
  13 +require 'spec_helper'
  14 +require 'whois/record/parser/whois.nic.uk.rb'
  15 +
  16 +describe Whois::Record::Parser::WhoisNicUk, "property_registrar_godaddy.expected" do
  17 +
  18 + subject do
  19 + file = fixture("responses", "whois.nic.uk/property_registrar_godaddy.txt")
  20 + part = Whois::Record::Part.new(:body => File.read(file))
  21 + described_class.new(part)
  22 + end
  23 +
  24 + describe "#registrar" do
  25 + it do
  26 + subject.registrar.should be_a(Whois::Record::Registrar)
  27 + subject.registrar.id.should == "GODADDY"
  28 + subject.registrar.name.should == "GoDaddy.com, LLP."
  29 + subject.registrar.name.should == "GoDaddy.com, LLP."
  30 + subject.registrar.url.should == nil
  31 + end
  32 + end
  33 +end

0 comments on commit 5eb2e30

Please sign in to comment.
Something went wrong with that request. Please try again.