Permalink
Browse files

whois.neworksolutions.com parser crashes when the contact name is blank.

  • Loading branch information...
weppos committed Jul 4, 2012
1 parent 0c5d5bc commit 3c61922eac0439b87ba857f8f23389c25a3fb657
Showing with 9 additions and 2 deletions.
  1. +2 −0 CHANGELOG.md
  2. +7 −2 lib/whois/record/parser/whois.networksolutions.com.rb
View
@@ -18,6 +18,8 @@
* NEW: whois.tznic.or.tz is now a full parser.
+* FIXED: whois.neworksolutions.com parser crashes when the contact name is blank.
+
* CHANGE: Deprecated options[:web] for :web adapter in favor of options[:url].
* CHANGE: Removed Pir adaper, the registry is a thick whois server.
@@ -88,7 +88,9 @@ def build_contact(element, type)
match = content_for_scanner.slice(/#{element}.*\n((.+\n){4,7})/, 1)
return unless match
- lines = match.split("\n").map(&:strip)
+ # Split lines but don't strip them now because in some cases
+ # we need the entire line, including extra-spaces.
+ lines = match.split("\n")
# 0 XIF Communications | mpowers LLC
# 1 1200 New Hampshire Avenue NW | 21010 Southbank St #575
@@ -106,11 +108,14 @@ def build_contact(element, type)
# Does the first line end in something that looks like a email address?
if lines[0].to_s =~ /\S+@\S+$/
+ # p lines.shift
# The record has a extra name and number line
name, email = lines.shift.scan(/^(.+)\s(\S+@\S+)$/).first
- name = name.strip
+ name = name.strip if name
end
+ lines.each(&:strip!)
+
# Does the last line contains the word fax, or has >9 digits
if lines[-1].to_s =~ / fax: /
phone, fax = lines.pop.to_s.scan(/^(.+) fax: (.+)$/).first

0 comments on commit 3c61922

Please sign in to comment.