Skip to content
Browse files

With some .se domains, whois.nic-se.se parser returns invalid values …

…for nameservers.
  • Loading branch information...
1 parent 3104034 commit 2191e196c48ab6150258b6c6ef154d05bb5415ef @weppos committed
View
2 CHANGELOG.rdoc
@@ -19,6 +19,8 @@
* FIXED: whois.crsnic.net server crashes trying to return nameservers with reserved IANA domains and Ruby 1.9.1.
+* FIXED: With some .se domains, whois.nic-se.se parser returns invalid values for nameservers.
+
== Release 1.0.4
View
4 lib/whois/answer/parser/whois.crsnic.net.rb
@@ -77,7 +77,8 @@ class WhoisCrsnicNet < Base
property_supported :expires_on do
node("Expiration Date") { |raw| Time.parse(raw) }
end
-
+
+
property_supported :nameservers do
@nameservers ||= node("Name Server") do |values|
[*values].map do |value|
@@ -87,6 +88,7 @@ class WhoisCrsnicNet < Base
@nameservers ||= []
end
+
property_supported :registrar do
# Return nil because when the response contains more than one registrar section
# the response can be messy. See, for instance, the Verisign response for google.com.
View
8 lib/whois/answer/parser/whois.nic-se.se.rb
@@ -66,8 +66,14 @@ class WhoisNicSeSe < Base
end
end
+ # Nameservers are listed in the following formats:
+ #
+ # nserver: ns2.loopia.se
+ # nserver: ns2.loopia.se 93.188.0.21
+ #
+ # In both cases, always return only the name.
property_supported :nameservers do
- @nameservers ||= content_for_scanner.scan(/nserver:\s+(.*)\n/).flatten
+ @nameservers ||= content_for_scanner.scan(/nserver:\s+(.*)\n/).flatten.map { |value| value.split(" ").first }
end
end
View
21 test/answer/parser/whois.nic-se.se_test.rb
@@ -48,11 +48,24 @@ def test_expires_on
@klass.new(load_part('/available.txt')).expires_on
end
+
def test_nameservers
- assert_equal %w(ns1.google.com ns2.google.com ns3.google.com ns4.google.com),
- @klass.new(load_part('/registered.txt')).nameservers
- assert_equal %w(),
- @klass.new(load_part('/available.txt')).nameservers
+ parser = @klass.new(load_part('/registered.txt'))
+ expected = %w( ns1.google.com ns2.google.com ns3.google.com ns4.google.com )
+ assert_equal expected, parser.nameservers
+ assert_equal expected, parser.instance_eval { @nameservers }
+
+ parser = @klass.new(load_part('/available.txt'))
+ expected = %w()
+ assert_equal expected, parser.nameservers
+ assert_equal expected, parser.instance_eval { @nameservers }
+ end
+
+ def test_nameservers_with_ip
+ parser = @klass.new(load_part('/nameservers_with_ip.txt'))
+ expected = %w( ns2.loopia.se ns4.loopia.se ns3.loopia.se ns1.loopia.se )
+ assert_equal expected, parser.nameservers
+ assert_equal expected, parser.instance_eval { @nameservers }
end
end
View
37 test/testcases/responses/whois.nic-se.se/nameservers_with_ip.txt
@@ -0,0 +1,37 @@
+# Copyright (c) 1997- .SE (The Internet Infrastructure Foundation).
+# All rights reserved.
+
+# The information obtained through searches, or otherwise, is protected
+# by the Swedish Copyright Act (1960:729) and international conventions.
+# It is also subject to database protection according to the Swedish
+# Copyright Act.
+
+# Any use of this material to target advertising or
+# similar activities is forbidden and will be prosecuted.
+# If any of the information below is transferred to a third
+# party, it must be done in its entirety. This server must
+# not be used as a backend for a search engine.
+
+# Result of search for registered domain names under
+# the .SE top level domain.
+
+# The data is in the UTF-8 character set and the result is
+# printed with eight bits.
+
+state: active
+domain: loopia.se
+holder: looloo8804-00001
+admin-c: -
+tech-c: -
+billing-c: -
+created: 2003-09-15
+modified: 2010-02-15
+expires: 2020-09-15
+transferred: 2009-03-09
+nserver: ns2.loopia.se 93.188.0.21
+nserver: ns4.loopia.se 93.188.0.20
+nserver: ns3.loopia.se 93.188.0.21
+nserver: ns1.loopia.se 93.188.0.20
+dnssec: unsigned delegation
+status: ok
+registrar: Loopia AB

0 comments on commit 2191e19

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