Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
00abedd
Update in.ua parser
jarthod Nov 9, 2021
0f13039
Update changelog and readme about fork status
jarthod Nov 9, 2021
c936b0c
Fix AFNIC parsers date format
itghlu Apr 4, 2019
e2b84e7
Big update and refactoring of all the Afilias based parser format, fi…
jarthod Nov 11, 2021
ab3af79
Make sure times are parsed as UTC when no zone is specified (instead …
jarthod Nov 16, 2021
4a7a81e
Fix throttled response detection for .CO.UK, .ME, .INFO, .MOBI (and m…
jarthod Nov 16, 2021
a5b0f63
Fix the parser for the .fi TLD (Closes: #42)
Mar 11, 2020
481c1bb
Updated parser for .CO tld
jarthod Nov 21, 2021
cbdfb21
Added parser for .CLOUD tld
jarthod Nov 21, 2021
5c97371
Add whois.nic.google
derekjc Jun 28, 2019
bbc4401
Added parser for .WORLD tld
jarthod Nov 23, 2021
ed7068c
Updated parser for .CA tld
jarthod Nov 25, 2021
6354c4e
Added support for all DonutsInc TLDs (241 at the time: .ACADEMY, .ACC…
jarthod Dec 7, 2021
1d7b586
Updated parser for .COM.AU tld (thanks @kovalevsky)
jarthod Dec 14, 2021
f71eab8
Fixed parser for .MX tld (and derivates: .COM.MX, .ORG.MX, etc.)
jarthod Dec 15, 2021
e8bc52a
Fixed parser for .IN tld
jarthod Dec 15, 2021
e0222f8
Added support for all (or fixing existing) CentralNic TLDs (136 at th…
jarthod Dec 16, 2021
399fd2a
Fixed .SO parser not loading correctly under jRuby + Add support for …
jarthod Dec 16, 2021
5136f03
Adding ruby 3 to the test suite + updating jruby and remove it from t…
jarthod Dec 16, 2021
98a4560
Add deleted status to nic_fr
Jan 25, 2022
a08d9bb
merge upstream
jarthod Nov 26, 2022
b9ade2f
Updated parser for .PT tld
jarthod Nov 26, 2022
0880e37
FIX: Updated parser for .CL tld
jarthod Jan 16, 2023
04e93b4
FIX: Updated parser for .SO tld
jarthod Jan 16, 2023
99b510c
Fixed support for all Donuts Inc. TLDs as they rebranded to Identity …
jarthod Mar 14, 2023
fc909d1
FIX: Updated parser for .RO tld
jarthod Jun 24, 2024
76b9501
Merge pull request #1 from Youness-e/master
jarthod Jun 24, 2024
27e61b4
fix active_support #presence require + update test matrix
jarthod Jan 16, 2025
66c5b03
Add ostruct to gemspec for Ruby 3.5
halilim Jan 3, 2025
bd7687f
whois.nic.consulting parser
ashlie-10fw Jan 16, 2025
b7f2012
Add registrar property support for Japanese (.jp) domains
usiegj00 Apr 18, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
8 changes: 0 additions & 8 deletions .github/dependabot.yml

This file was deleted.

12 changes: 5 additions & 7 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,18 @@ on:
jobs:
build:
strategy:
fail-fast: false
matrix:
ruby-version:
- "2.6"
- "2.7"
- "3.0"
- "3.1"
ruby: ['2.7', '3.0', '3.1', '3.2', '3.3', '3.4', head, jruby, jruby-head, truffleruby, truffleruby-head]
platform: [ubuntu-latest]
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
- name: Install dependencies
run: bundle install
- name: Run tests
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
/.bundle/
/Gemfile.lock
/pkg/
.ruby-version

# YARD
/.yardoc
Expand Down
26 changes: 25 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,32 @@ This project uses [Semantic Versioning 2.0.0](http://semver.org/).

#### Release 2.0.0

- FIX: Updated parser for .RO tld
- FIX: Fixed support for all Donuts Inc. TLDs as they rebranded to Identity Digital Inc.
- FIX: Updated parser for .SO tld
- FIX: Updated parser for .CL tld
- FIX: Updated parser for .PT tld
- CHANGED: Adding ruby 3 to the test suite + updating jruby and remove it from the allowed failures
- FIX: Fixed .SO parser not loading correctly under jRuby
- NEW: Add support for ActiveSupport 7 + reduce ActiveSupport usage for Array.wap
- NEW: Added support for all (or fixing existing) CentralNic TLDs (136 at the time: .ADAC, .AE.ORG, .ALLFINANZ, .ART, .AUTO, .AUTOS, .BABY, .BAR, .BEAUTY, .BEST, .BH, .BLOG, .BMW, .BOATS, .BOND, .BOX, .BR.COM, .BUILD, .CAM, .CAR, .CARS, .CASE, .CEO, .CFD, .CN.COM, .CO.COM, .CO.NL, .CO.NO, .CO.RO, .COLLEGE, .COM.DE, .COM.SE, .COOP, .CYOU, .DE.COM, .DEALER, .DELOITTE, .DESI, .DESIGN, .DHL, .DVAG, .ETISALAT, .EU.COM, .FANS, .FEEDBACK, .FM, .FO, .FORUM, .FRESENIUS, .FRL, .FUN, .GAY, .GB.NET, .GD, .GENT, .GR.COM, .HAIR, .HOMES, .HOST, .HU.NET, .ICU, .IN.NET, .INC, .INK, .JP.NET, .JPN.COM, .KFH, .KPN, .KRED, .LIDL, .LONDON, .LOVE, .LPL, .LPLFINANCIAL, .LUXURY, .MAKEUP, .MEX.COM, .MINI, .MONSTER, .MOTORCYCLES, .MUSIC, .ONLINE, .OOO, .PID, .POHL, .PRESS, .PROTECTION, .PW, .QPON, .QUEST, .RADIO.AM, .REIT, .RENT, .REST, .RU.COM, .SA.COM, .SAARLAND, .SBS, .SCHWARZ, .SE.NET, .SECURITY, .SFR, .SHOP.RO, .SITE, .SKIN, .SMART, .SPACE, .STC, .STCGROUP, .STORAGE, .STORE, .TECH, .THEATRE, .TICKETS, .TUI, .UK.COM, .UK.NET, .UNO, .US.COM, .US.ORG, .VG, .VIVA, .WEBSITE, .WIKI, .WME, .موقع, .اتصالات, .البحرين, .بيتك, .VERMÖGENSBERATER, .VERMÖGENSBERATUNG, .XYZ, .YACHTS, .ZA.BZ, .ZA.COM, .ZUERICH)
- FIX: Updated parser for .IN tld which changed name
- FIX: Updated parser for .MX tld (and derivates: .COM.MX, .ORG.MX, etc.) which changed name
- FIX: Updated parser for .COM.AU tld (based on #100) Thanks @kovalevsky
- NEW: Added support for all DonutsInc TLDs (241 at the time: .ACADEMY, .ACCOUNTANTS, .ACTOR, .AGENCY, .AIRFORCE, .APARTMENTS, .ARMY, .ASSOCIATES, .ATTORNEY, .AUCTION, .BAND, .BARGAINS, .BIKE, .BINGO, .BOUTIQUE, .BUILDERS, .BUSINESS, .CAB, .CAFE, .CAMERA, .CAMP, .CAPITAL, .CARDS, .CARE, .CAREERS, .CASH, .CASINO, .CATERING, .CENTER, .CHARITY, .CHAT, .CHEAP, .CHURCH, .CITY, .CLAIMS, .CLEANING, .CLINIC, .CLOTHING, .COACH, .CODES, .COFFEE, .COMMUNITY, .COMPANY, .COMPUTER, .CONDOS, .CONSTRUCTION, .CONTACT, .CONTRACTORS, .COOL, .COUPONS, .CREDIT, .CREDITCARD, .CRUISES, .DANCE, .DATING, .DEALS, .DEGREE, .DELIVERY, .DEMOCRAT, .DENTAL, .DENTIST, .DIAMONDS, .DIGITAL, .DIRECT, .DIRECTORY, .DISCOUNT, .DOCTOR, .DOG, .DOMAINS, .EDUCATION, .EMAIL, .ENERGY, .ENGINEER, .ENGINEERING, .ENTERPRISES, .EQUIPMENT, .ESTATE, .EVENTS, .EXCHANGE, .EXPERT, .EXPOSED, .EXPRESS, .FAIL, .FAMILY, .FAN, .FARM, .FINANCE, .FINANCIAL, .FISH, .FITNESS, .FLIGHTS, .FLORIST, .FOOTBALL, .FORSALE, .FOUNDATION, .FUND, .FURNITURE, .FUTBOL, .FYI, .GALLERY, .GAMES, .GIFTS, .GIVES, .GLASS, .GMBH, .GOLD, .GOLF, .GRAPHICS, .GRATIS, .GRIPE, .GROUP, .GUIDE, .GURU, .HAUS, .HEALTHCARE, .HOCKEY, .HOLDINGS, .HOLIDAY, .HOSPITAL, .HOUSE, .IMMO, .IMMOBILIEN, .INDUSTRIES, .INSTITUTE, .INSURE, .INTERNATIONAL, .INVESTMENTS, .IRISH, .JETZT, .JEWELRY, .KAUFEN, .KITCHEN, .LAND, .LAWYER, .LEASE, .LEGAL, .LIFE, .LIGHTING, .LIMITED, .LIMO, .LIVE, .LOANS, .LTD, .MAISON, .MANAGEMENT, .MARKET, .MARKETING, .MBA, .MEDIA, .MEMORIAL, .MODA, .MONEY, .MORTGAGE, .MOVIE, .NAVY, .NETWORK, .NEWS, .NINJA, .PARTNERS, .PARTS, .PHOTOGRAPHY, .PHOTOS, .PICTURES, .PIZZA, .PLACE, .PLUMBING, .PLUS, .PRODUCTIONS, .PROPERTIES, .PUB, .RECIPES, .REHAB, .REISE, .REISEN, .RENTALS, .REPAIR, .REPORT, .REPUBLICAN, .RESTAURANT, .REVIEWS, .RIP, .ROCKS, .RUN, .SALE, .SALON, .SARL, .SCHOOL, .SCHULE, .SERVICES, .SHOES, .SHOPPING, .SHOW, .SINGLES, .SOCCER, .SOCIAL, .SOFTWARE, .SOLAR, .SOLUTIONS, .STUDIO, .STYLE, .SUPPLIES, .SUPPLY, .SUPPORT, .SURGERY, .SYSTEMS, .TAX, .TAXI, .TEAM, .TECHNOLOGY, .TENNIS, .THEATER, .TIENDA, .TIPS, .TIRES, .TODAY, .TOOLS, .TOURS, .TOWN, .TOYS, .TRAINING, .TRAVEL, .UNIVERSITY, .VACATIONS, .VENTURES, .VET, .VIAJES, .VIDEO, .VILLAS, .VIN, .VISION, .VOYAGE, .WATCH, .WINE, .WORKS, .WORLD, .WTF, .ZONE, .企业, .娱乐, .游戏, .商店)
- FIX: Updated parser for .CA tld
- NEW: Added parser for .WORLD tld
- NEW: Add whois.nic.google (support for .APP, .DEV, .HOW, .PAGE, .SOY) and update xn--q9jyb4c (.みんな) to use whois.nic.google (based on #124) Thanks @derekjc
- NEW: Added parser for .CLOUD tld
- FIX: Updated parser for .CO tld
- FIX: Updated parser for .FI tld (based on #133) Thanks @elguitar
- FIX: Fix throttled response detection for .CO.UK, .ME, .INFO, .MOBI (and most other Afilias based)
- CHANGED: Make sure times are parsed as UTC when no zone is specified (instead of using machine timezone) + improve parsing of some timezone when present and set japanese timezone.
- FIX: Big update and refactoring of all the Afilias based parser format, fixing broken parsing for .ME, .ORG, .INFO, .PRO, .BZ, .GI, .LC, .MN, .SC, .VC, .AG, .IN, .AERO, .ASIA, .MOBI, .POST, .XXX. (based on #34) Thanks @raszi and @jarthod
- CHANGED: Standardize a bit more the Registar object by always filling the name first (instead of sometimes filling organisation instead and sometimes duplicate both). Only fill "organization" when it's a real different property provided by the whois server.
- FIX: AFNIC parsers date format to avoid returning negative dates (#119) Thanks @itghlu
- CHANGED: Updated .IN.UA parsers to the latest response. (#69, #135) Thanks @Vanav and @jarthod
- CHANGED: Minimum Ruby version 2.6

- FIXED: Addressed security issues with eval and YAML.load. Thanks Francis Beaudoin


Expand Down
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
⚠️ WARNING: this repository is a fork of https://github.com/weppos/whois-parser. I created it because the maintainer seems [to have paused](https://github.com/weppos/whois-parser/pull/135) so the project was lagging more and more behind actual WHOIS definitions and the [PR piling up](https://github.com/weppos/whois-parser/pulls). I hope we'll be able to merge this back into the main project eventually but in the meantime if you need a more up-to-date and maintained version you can use this one:

Gemfile:
```ruby
gem 'whois-parser', github: 'jarthod/whois-parser' # Unofficial but more up-to-date fork, check status at https://github.com/jarthod/whois-parser
```

I'll try to merge as much existing PR as possible into this fork and provide my own updates too. I don't want to release the gem under another name at the moment to make it easier to go back to the official gem if possible, if so I'll update this page so you can check it from time to time when you see this comment in your Gemfile. The [CHANGELOG](CHANGELOG.md) file will be updated with all the changes in this fork, you can compare it with the upstream [CHANGELOG](https://github.com/weppos/whois-parser/blob/master/CHANGELOG.md)

Below is the unmodified upstream Readme to make merging easier.

---

# [Whois](https://whoisrb.org/) Parser

<tt>Whois Parser</tt> is a — pure Ruby — WHOIS parser.
Expand Down
4 changes: 4 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,7 @@ CLOBBER.include "yardoc"
Dir["tasks/**/*.rake"].each do |file|
load(file)
end

task :console do
system "irb -r rubygems -I lib -r whois-parser.rb"
end
47 changes: 26 additions & 21 deletions lib/whois/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,9 @@


require 'whois'
require 'active_support/core_ext/array/extract_options'
require 'active_support/core_ext/array/wrap'
require 'active_support/core_ext/class/attribute'
require 'active_support/core_ext/kernel/singleton_class'
require 'active_support'
require 'active_support/core_ext/object/blank'
require 'active_support/core_ext/class/attribute'
require 'active_support/core_ext/time/calculations'

require_relative 'parser/version'
Expand Down Expand Up @@ -91,9 +89,8 @@ def self.bug!(error, message)
PROPERTY_STATE_SUPPORTED = :supported


# Returns the proper parser instance for given <tt>part</tt>.
# The parser class is selected according to the
# value of the <tt>#host</tt> attribute for given <tt>part</tt>.
# Instanciate the proper parser instance for given <tt>part</tt>.
# The parser class is determined using <tt>.parser_for</tt>
#
# @param [Whois::Record::Part] part The part to get the parser for.
#
Expand All @@ -112,37 +109,43 @@ def self.bug!(error, message)
# # => #<Whois::Parsers::Blank>
#
def self.parser_for(part)
parser_klass(part.host).new(part)
rescue LoadError
Parsers.const_defined?("Blank") || autoload("blank")
Parsers::Blank.new(part)
parser_klass(part).new(part)
end

# Detects the proper parser class according to given <tt>host</tt>
# Detects the proper parser class according to given <tt>part</tt>
# and returns the class constant.
# The parser class is selected according to the values of the
# <tt>#host</tt> and <tt>#body</tt> attributes for given <tt>part</tt>.
#
# This method autoloads missing parser classes. If you want to define
# a custom parser, simple make sure the class is loaded in the Ruby
# environment before this method is called.
#
# @param [String] host The server host.
# @param [Whois::Record::Part] part The part to get the parser for.
#
# @return [Class] The instance of Class representing the parser Class
# corresponding to <tt>host</tt>. If <tt>host</tt> doesn't have
# corresponding to <tt>part</tt>. If <tt>part</tt> doesn't have
# a specific parser implementation, then returns
# the {Whois::Parsers::Blank} {Class}.
# The {Class} is expected to be a child of {Whois::Parsers::Base}.
# @raises LoadError If the class is not found.
#
# @example
#
# Parser.parser_klass("whois.example.com")
# Parser.parser_klass(Whois::Record::Part.new(host: "whois.example.com"))
# # => Whois::Parsers::WhoisExampleCom
#
def self.parser_klass(host)
name = host_to_parser(host)
Parsers.const_defined?(name) || autoload(host)
Parsers.const_get(name)
def self.parser_klass(part)
autoload(part.host)
rescue LoadError
# Some WHOIS services like Donuts Inc covers hundred of TLDs (https://donuts.domains/what-we-do/top-level-domain-portfolio/)
# But using one host per TLD, so in this case it's easier to match on the disclaimer directly to cover all hosts
if part.body&.include?("Terms of Use: Identity Digital Inc.")
autoload("donuts_inc")
elsif part.body&.include?("The Whois and RDAP services are provided by CentralNic")
autoload("central_nic")
else
autoload("blank")
end
end

# Converts <tt>host</tt> to the corresponding parser class name.
Expand Down Expand Up @@ -172,7 +175,9 @@ def self.host_to_parser(host)
# @return [void]
#
def self.autoload(name)
require "whois/parsers/#{name}"
class_name = host_to_parser(name)
require_relative "parsers/#{name}.rb" unless Parsers.const_defined?(class_name)
Parsers.const_get(class_name)
end


Expand Down
25 changes: 12 additions & 13 deletions lib/whois/parsers/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
require_relative '../parser/nameserver'
require_relative '../scanners/scannable'


module Whois
class Parsers

Expand Down Expand Up @@ -169,12 +168,10 @@ def property_supported?(property)
# @return [Nil] if the timestamp can't be parsed
# @return [Time]
#
def self.parse_time(timestamp)
def self.parse_time(timestamp, timezone: 'UTC')
return unless timestamp.is_a?(String) && !timestamp.empty?

Time.parse(timestamp).change(usec: 0)
rescue ArgumentError
nil
zone = Time.find_zone(timezone) or raise ArgumentError.new("Invalid timezone: #{timezone.inspect}")
zone.parse(timestamp)&.change(usec: 0)
end

# @return [Whois::Record::Part] The part referenced by this parser.
Expand Down Expand Up @@ -377,16 +374,18 @@ def cached_properties_fetch(key)

private

def typecast(value, type)
if Array == type
Array.wrap(value)
def wrap(object)
if object.nil?
[]
elsif object.respond_to?(:to_ary)
object.to_ary || [object]
else
value
[object]
end
end

def parse_time(timestamp)
self.class.parse_time(timestamp)
def parse_time(timestamp, **args)
self.class.parse_time(timestamp, **args)
end

def handle_property(property, *args)
Expand All @@ -400,7 +399,7 @@ def handle_property(property, *args)

case property.to_s
when /_contacts$/, "nameservers"
typecast(value, Array)
wrap(value)
else
value
end
Expand Down
Loading