lib/Net/Domain/ExpireDate.pm

filter: Statementstmt 79.8% 254 / 318 Branchbran 77.2% 136 / 176 Conditioncond 73.2% 41 / 56 MC/DCmcdc 45.1% 14 / 31 Subroutinesub 96.1% 25 / 26 Podpod 75.0% 6 / 8 totaltotal 77.4% 476 / 615 SCAR 54.6
CC
111
Cov
78%
_expdate_int_cno
41.0
_dates_int_ru
34.5
_credate_int_cno
32.7
CRAP 235.8
« blib/lib/Net/Domain/ExpireDate.pm ↑ Summary Build »
1 package Net::Domain::ExpireDate;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use Time::Piece;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use Net::Whois::Raw;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use Encode;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 1 ▶use constant FLG_EXPDATE => 0b0001;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use constant FLG_CREDATE => 0b0010;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use constant FLG_ALL => 0b1111;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 1 ▶use constant ONE_DAY => 86_400;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 1 ▶use constant ONE_YEAR => 31_556_930; # 365.24225 days
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 1 our @EXPORT = qw(
17 expire_date expdate_int expdate_fmt credate_fmt domain_dates domdates_fmt
18 $USE_REGISTRAR_SERVERS
19 );
20  
21 1 our $VERSION = '1.18';
22  
23 1 our $USE_REGISTRAR_SERVERS;
24 1 our $CACHE_DIR;
25 1 our $CACHE_TIME;
26  
27 1 $USE_REGISTRAR_SERVERS = 0;
28 # 0 - make queries to registry server
29 # 1 - make queries to registrar server
30 # 2 - make queries to registrar server and in case of fault make query to registry server
31  
32 # for Net::Whois::Raw
33 1 $Net::Whois::Raw::OMIT_MSG = 2;
34 1 $Net::Whois::Raw::CHECK_FAIL = 3;
35  
36 sub expire_date {
37 4 ▶ my ( $domain, $format ) = @_;
Subroutine expire_date: called CC=5 SCAR=20.9
Pod documented
38  
39 4 ▶ if ( $USE_REGISTRAR_SERVERS == 0 ) {
Branch: 3 branches
BranchTrueFalseTotal
if ($Net::Domain::ExpireDate::USE_REGISTRAR_SERVERS == 0) { } 0 4 4
elsif ($Net::Domain::ExpireDate::USE_REGISTRAR_SERVERS == 1) { } 0 4 4
elsif ($Net::Domain::ExpireDate::USE_REGISTRAR_SERVERS == 2) { } 4 0 4
40 0 return _expire_date_query( $domain, $format, 1 );
41 }
42 elsif ( $USE_REGISTRAR_SERVERS == 1 ) {
43 0 return _expire_date_query( $domain, $format, 0 );
44 }
45 elsif ( $USE_REGISTRAR_SERVERS == 2 ) {
46 4 ▶ return _expire_date_query( $domain, $format, 0 )
Condition33%1/3
_expire_date_query($domain, $format, 0) || _expire_date_query($domain, $format, 1)
l!l&&r!l&&!r
400
MC/DC0%0/2
_expire_date_query($domain, $format, 0) || _expire_date_query($domain, $format, 1)
_expire_date_query($domain, $format, 0) _expire_date_query($domain, $format, 1)
Truth table33%1/3
A || B
A= _expire_date_query($domain, $format, 0)B= _expire_date_query($domain, $format, 1)
ABresult
1X1
011
000
47 || _expire_date_query( $domain, $format, 1 );
48 }
49 }
50  
51 sub domain_dates {
52 5 ▶ my ( $domain, $format ) = @_;
Subroutine domain_dates: called CC=7 SCAR=21.8
Pod documented
53  
54 5 _config_netwhoisraw();
55  
56 5 ▶ return unless $domain =~ /(.+?)\.([^.]+)$/;
Branch: 1 branch
BranchTrueFalseTotal
unless $domain =~ /(.+?)\.([^.]+)$/ 0 5 5
57 5 my ( $name, $tld ) = ( lc $1 , lc $2 );
58  
59 5 my $whois;
60  
61 5 ▶ if ( $USE_REGISTRAR_SERVERS == 0 ) {
Branch: 3 branches
BranchTrueFalseTotal
if ($Net::Domain::ExpireDate::USE_REGISTRAR_SERVERS == 0) { } 1 4 5
elsif ($Net::Domain::ExpireDate::USE_REGISTRAR_SERVERS == 1) { } 0 4 4
elsif ($Net::Domain::ExpireDate::USE_REGISTRAR_SERVERS == 2) { } 4 0 4
62 1 $whois = Net::Whois::Raw::whois( $domain, undef, 'QRY_FIRST' );
63 }
64 elsif ( $USE_REGISTRAR_SERVERS == 1 ) {
65 0 $whois = Net::Whois::Raw::whois( $domain, undef, 'QRY_LAST' );
66 }
67 elsif ( $USE_REGISTRAR_SERVERS == 2 ) {
68 4 ▶ $whois = Net::Whois::Raw::whois( $domain, undef, 'QRY_LAST' )
Condition33%1/3
Net::Whois::Raw::whois($domain, undef, 'QRY_LAST') || Net::Whois::Raw::whois($domain, undef, 'QRY_FIRST')
l!l&&r!l&&!r
400
MC/DC0%0/2
Net::Whois::Raw::whois($domain, undef, 'QRY_LAST') || Net::Whois::Raw::whois($domain, undef, 'QRY_FIRST')
Net::Whois::Raw::whois($domain, undef, 'QRY_LAST') Net::Whois::Raw::whois($domain, undef, 'QRY_FIRST')
Truth table33%1/3
A || B
A= Net::Whois::Raw::whois($domain, undef, 'QRY_LAST')B= Net::Whois::Raw::whois($domain, undef, 'QRY_FIRST')
ABresult
1X1
011
000
69 || Net::Whois::Raw::whois( $domain, undef, 'QRY_FIRST' )
70 }
71  
72 5 ▶ return domdates_fmt( $whois, $tld, $format ) if $format;
Branch: 1 branch
BranchTrueFalseTotal
if $format 5 0 5
73  
74 0 return domdates_int( $whois, $tld );
75 }
76  
77 sub _expire_date_query {
78 4 ▶ my ( $domain, $format, $via_registry ) = @_;
Subroutine _expire_date_query: called CC=4 SCAR=15.0
79  
80 4 _config_netwhoisraw();
81  
82 4 ▶ return unless $domain =~ /(.+?)\.([^.]+)$/;
Branch: 1 branch
BranchTrueFalseTotal
unless $domain =~ /(.+?)\.([^.]+)$/ 0 4 4
83 4 my ( $name, $tld ) = ( lc $1, lc $2 );
84  
85 4 ▶ my $whois = Net::Whois::Raw::whois( $domain, undef, $via_registry ? 'QRY_FIRST' : 'QRY_LAST' );
Branch: 1 branch
BranchTrueFalseTotal
$via_registry ? : 0 4 4
86  
87 4 ▶ return expdate_fmt( $whois, $tld, $format ) if $format;
Branch: 1 branch
BranchTrueFalseTotal
if $format 4 0 4
88  
89 0 return expdate_int( $whois, $tld );
90 }
91  
92 sub domdates_fmt {
93 83 ▶ my ( $whois, $tld, $format, $flags ) = @_;
Subroutine domdates_fmt: called CC=5 SCAR=16.1
Pod documented
94 83 ▶ $format ||= '%Y-%m-%d';
Condition100%2/2
$format ||= "%Y-%m-%d"
l!l
1271
MC/DC100%1/1
$format ||= "%Y-%m-%d"
$format
Truth table100%2/2
A
A= $format
Aresult
11
00
95  
96 83 my ( $cre_date, $exp_date, $fre_date ) = domdates_int( $whois, $tld, $flags );
97  
98 83 local $^W = 0; # prevent warnings
99  
100 83 ▶ $cre_date = $cre_date ? $cre_date->strftime( $format ) : '';
Branch: 1 branch
BranchTrueFalseTotal
$cre_date ? : 23 60 83
101 83 ▶ $exp_date = $exp_date ? $exp_date->strftime( $format ) : '';
Branch: 1 branch
BranchTrueFalseTotal
$exp_date ? : 73 10 83
102 83 ▶ $fre_date = $fre_date ? $fre_date->strftime( $format ) : '';
Branch: 1 branch
BranchTrueFalseTotal
$fre_date ? : 6 77 83
103  
104 83 return $cre_date, $exp_date, $fre_date;
105 }
106  
107 sub expdate_fmt {
108 63 ▶ my ( $whois, $tld, $format ) = @_;
Subroutine expdate_fmt: called CC=1 SCAR=0.0
Pod documented
109  
110 63 my ( $cre_date, $exp_date ) = domdates_fmt( $whois, $tld, $format, FLG_EXPDATE );
111  
112 63 return $exp_date;
113 }
114  
115 sub credate_fmt {
116 10 ▶ my ( $whois, $tld, $format ) = @_;
Subroutine credate_fmt: called CC=1 SCAR=0.0
Pod undocumented
117  
118 10 my ( $cre_date, $exp_date ) = domdates_fmt( $whois, $tld, $format, FLG_CREDATE );
119  
120 10 return $cre_date;
121 }
122  
123 sub domdates_int {
124 83 ▶ my ( $whois, $tld, $flags ) = @_;
Subroutine domdates_int: called CC=8 SCAR=20.8
Pod documented
125 83 ▶ $tld ||= 'com';
Condition100%2/2
$tld ||= "com"
l!l
2657
MC/DC100%1/1
$tld ||= "com"
$tld
Truth table100%2/2
A
A= $tld
Aresult
11
00
126 83 ▶ $flags ||= FLG_ALL;
Condition100%2/2
$flags ||= 15
l!l
7310
MC/DC100%1/1
$flags ||= 15
$flags
Truth table100%2/2
A
A= $flags
Aresult
11
00
127  
128 83 ▶ if ( _isin( $tld, [ qw( ru su xn--p1ai pp.ru net.ru org.ru ) ] ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (_isin($tld, ["ru", "su", "xn--p1ai", "pp.ru", "net.ru", "org.ru"])) 13 70 83
129 13 return _dates_int_ru( $whois );
130 }
131  
132 70 ▶ if ( $tld eq 'jp' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tld eq "jp") 1 69 70
133 1 ▶ $whois = eval { Encode::decode( 'UTF-8', $whois ) } || $whois;
Condition33%1/3
eval { do { &Encode::decode('UTF-8', $whois) } } || $whois
l!l&&r!l&&!r
010
MC/DC0%0/2
eval { do { &Encode::decode('UTF-8', $whois) } } || $whois
eval { do { &Encode::decode('UTF-8', $whois) } } $whois
Truth table33%1/3
A || B
A= eval { do { &Encode::decode('UTF-8', $whois) } }B= $whois
ABresult
1X1
011
000
134 }
135  
136 70 ▶ my $expdate = $flags & FLG_EXPDATE ? _expdate_int_cno( $whois ) : undef;
Branch: 1 branch
BranchTrueFalseTotal
$flags & 1 ? : 60 10 70
137 70 ▶ my $credate = $flags & FLG_CREDATE ? _credate_int_cno( $whois ) : undef;
Branch: 1 branch
BranchTrueFalseTotal
$flags & 2 ? : 16 54 70
138  
139 70 return $credate, $expdate;
140 }
141  
142 sub expdate_int {
143 0 ▶ my ( $whois, $tld ) = @_;
Subroutine expdate_int: not called CC=1 SCAR=6.9
Pod documented
144  
145 0 my ( $cre_date, $exp_date, $fre_date ) = domdates_int( $whois, $tld, 1 );
146  
147 0 return $exp_date;
148 }
149  
150 sub decode_date {
151 109 ▶ my ( $date, $format) = @_;
Subroutine decode_date: called CC=4 SCAR=14.6
Pod undocumented
152 109 ▶ return unless $date;
Branch: 1 branch
BranchTrueFalseTotal
unless $date 10 99 109
153 99 ▶ $format ||= '%Y-%m-%d';
Condition50%1/2
$format ||= "%Y-%m-%d"
l!l
990
MC/DC0%0/1
$format ||= "%Y-%m-%d"
$format
Truth table50%1/2
A
A= $format
Aresult
11
00
154  
155 99 my $t = eval { Time::Piece->strptime( $date, $format ) };
156  
157 99 ▶ if ( $@ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 99 99
158 0 warn "Can't parse date: ($date, $format)";
159 0 return;
160 }
161  
162 99 return $t;
163 }
164  
165 # --- internal functions ----
166  
167 sub _config_netwhoisraw {
168 9 ▶ $Net::Whois::Raw::CACHE_DIR = $CACHE_DIR if $CACHE_DIR ;
Subroutine _config_netwhoisraw: called CC=3 SCAR=12.0
Branch: 1 branch
BranchTrueFalseTotal
if $CACHE_DIR 0 9 9
169 9 ▶ $Net::Whois::Raw::CACHE_TIME = $CACHE_TIME if $CACHE_TIME;
Branch: 1 branch
BranchTrueFalseTotal
if $CACHE_TIME 0 9 9
170 }
171  
172 # extract expiration date from whois output
173 sub _expdate_int_cno {
174 60 ▶ my ( $whois ) = @_;
Subroutine _expdate_int_cno: called CC=31 SCAR=37.1
175 60 ▶ return unless $whois;
Branch: 1 branch
BranchTrueFalseTotal
unless $whois 0 60 60
176  
177 # $Y - The year, including century
178 # $y - The year within century (0-99)
179 # $m - The month number (1-12)
180 # $b - The month name
181 # $d - The day of month (1-31)
182 60 my ( $rulenum, $Y, $y, $m, $b, $d );
183  
184 # [whois.networksolutions.com] Record expires on 27-Apr-2011.
185 # [whois.opensrs.net]
186 # [whois.namesdirect.com]
187 # [whois.dotregistrar.com]
188 # [whois.domaininfo.com] Domain expires: 24 Oct 2010
189 # [whois.ibi.net] Record expires on........: 03-Jun-2005 EST.
190 # [whois.gkg.net] Expires on..............: 24-JAN-2003
191 # [whois.enom.com] Expiration date: 11 Jun 2005 14:22:48
192 60 ▶ if ( $whois =~ m/\sexpir.+?:?\s+(\d{2})[- ](\w{3})[- ](\d{4})/is ) {
Branch: 21 branches
BranchTrueFalseTotal
if ($whois =~ /\sexpir.+?:?\s+(\d{2})[- ](\w{3})[- ](\d{4})/is) { } 6 54 60
elsif ($whois =~ /(?:Expi\w+|Renewal) (?:Date|On):\s*(\d{2})-(\w{3})-(\d{4})/is) { } 2 52 54
elsif ($whois =~ m[(?:Record |Domain )?(?:will )?(?:be )?expir(?:e|ed|es|ing|ation)(?: on)?(?: date)?\s*[-:]?\s*(\d{4})[/-](\d{1,2})[/-](\d{1,2})]is) { } 21 31 52
elsif ($whois =~ m[(?:Expiry|Expiry Date|expire-date|Expire(?:d|s)? on|Valid[ -][Dd]ate|[Ee]xpiration [Dd]ate|Date of expiration|Renewal[- ][Dd]ate)(?:\.*|\s*):?\s+(\d{4})[/.-] ?(\d{2})[/.-] ?(\d{2})]is) { } 8 23 31
elsif ($whois =~ /expires?:\s+(\d{4})(\d{2})(\d{2})/is) { } 1 22 23
elsif ($whois =~ m[(?:validity|Expiry Date|expires?(?:\.*)(?: at)?|expiration date(?: \(dd/mm/yyyy\))?):\s+(\d{1,2})[./-](\d{1,2})[./-](\d{4})]is) { } 1 21 22
elsif ($whois =~ /Expires on\.*: (\d{2})-(\w{3})-(\d{2})/s) { } 1 20 21
elsif ($whois =~ /(?:Record )?expires(?: on)?\.* ?:? +(?:\w{3}, )?(\w{3,9})\s{1,2}(\d{1,2}),? (\d{4})/is) { } 7 13 20
elsif ($whois =~ /(?:Created|Expires) (?:on|after)\s?\.*:?\s*\w{3},? (\w{3})\s{1,2}(\d{1,2})(?: \d{2}:\d{2}:\d{2})? (\d{4})?/is) { } 2 11 13
elsif ($whois =~ /(?:Domain )?(?:Expires|Expiration Date):\s+\w{3} (\w{3}) (\d{2}) (?:\d{2}:\d{2}:\d{2} \w{3}(?:[-+]\d{2}:\d{2})? )(\d{4})/is) { } 0 11 11
elsif ($whois =~ /expires.+?(\d{2})-(\d{2})-(\d{4})/is) { } 3 8 11
elsif ($whois =~ m[(?:Expiration|Expires on):? (\d{1,2})[-/](\d{1,2})[-/](\d{4})]is) { } 2 6 8
elsif ($whois =~ /Expiration Date.+?(\d{2})-(\d{2})-(\d{4}) \d{2}:\d{2}:\d{2}/is) { } 0 6 6
elsif ($whois =~ /Registered on.+?(\d{2})-(\w{3})-(\d{4})/is) { } 0 6 6
elsif ($whois =~ /(?:Record |Domain )?expires on\.*:? (\d{4})-(\w{3})-(\d{1,2})/is) { } 3 3 6
elsif ($whois =~ m[Expiration date: (\d{2})/(\d{2})/(\d{2})]s) { } 1 2 3
elsif ($whois =~ /Registered through- (\w{3}) (\w{3}) (\d{2}) (\d{4})/is) { } 0 2 2
elsif ($whois =~ m[Expires: (\d{2})/(\d{2})/(\d{2})]is) { } 0 2 2
elsif ($whois =~ m[Registered through- (\d{2})/(\d{2})/(\d{2})]is) { } 0 2 2
elsif ($whois =~ m( \[\x{6709}\x{52b9}\x{671f}\x{9650}\] \s+ ( \d{4} ) / ( \d{2} ) / ( \d{2} ))sx) { } 1 1 2
elsif ($whois =~ /status:\s+OK-UNTIL (\d{4})(\d{2})(\d{2})\d{6}/s) { } 1 0 1
193 6 $rulenum = 1.1; $d = $1; $b = $2; $Y = $3;
194 # [whois.discount-domain.com] Expiration Date: 02-Aug-2003 22:07:21
195 # [whois.publicinterestregistry.net] Expiration Date:03-Mar-2004 05:00:00 UTC
196 # [whois.crsnic.net] Expiration Date: 21-sep-2004
197 # [whois.nic.uk] Renewal Date: 23-Jan-2006
198 # [whois.aero] Expires On:18-May-2008 01:53:51 UTC
199 # [whois.nic.me] Domain Expiration Date:28-Aug-2012 17:57:10 UTC
200 # [whois.domainregistry.ie]
201 } elsif ( $whois =~ m/(?:Expi\w+|Renewal) (?:Date|On):\s*(\d{2})-(\w{3})-(\d{4})/is ) {
202 2 $rulenum = 1.2; $d = $1; $b = $2; $Y = $3;
203 # [whois.bulkregister.com] Record expires on 2003-04-25
204 # [whois.bulkregister.com] Record will be expiring on date: 2003-04-25
205 # [whois.bulkregister.com] Record expiring on - 2003-04-25
206 # [whois.bulkregister.com] Record will expire on - 2003-04-25
207 # [whois.bulkregister.com] Record will be expiring on date: 2003-04-25
208 # [whois.eastcom.com]
209 # [whois.corenic.net] Record expires: 2003-07-29 10:45:05 UTC
210 # [whois.gandi.net] expires: 2003-05-21 10:09:56
211 # [whois.dotearth.com] Record expires on: 2010-04-07 00:00:00.0 ET
212 # [whois.names4ever.com] Record expires on 2012-07-15 10:23:10.000
213 # [whois.OnlineNIC.com] Record expired on 2008/8/26
214 # [whois.ascio.net] Record expires: 2003-03-12 12:16:45
215 # [whois.totalnic.net] Record expires on 2010-04-24 16:03:20+10
216 # [whois.signaturedomains.com] Expires on: 2003-11-05
217 # [whois.1stdomain.net] Domain expires: 2007-01-20.
218 # [whois.easyspace.com]
219 # [whois.centralnic.com] Expiration Date:2014-05-13T23:59:59.0Z
220 } elsif ( $whois =~ m&(?:Record |Domain )?(?:will )?(?:be )?expir(?:e|ed|es|ing|ation)(?: on)?(?: date)?\s*[-:]?\s*(\d{4})[/-](\d{1,2})[/-](\d{1,2})&is ) {
221 21 $rulenum = 2.1; $Y = $1; $m = $2; $d = $3;
222 # [whois.InternetNamesWW.com] Expiry Date.......... 2009-06-16
223 # [whois.aitdomains.com] Expire on................ 2002-11-05 16:42:41.000
224 # [whois.yesnic.com] Valid Date 2010-11-02 05:21:35 EST
225 # [whois.enetregistry.net] Expiration Date : 2002-11-19 04:18:25-05
226 # [whois.enterprice.net] Date of expiration : 2003-05-28 11:50:58
227 # [nswhois.domainregistry.com] Expires on..............: 2006-07-24
228 # [whois.cira.ca] Renewal date: 2006/10/27
229 # [whois.cira.ca] Expiry date: 2015/12/27
230 # [whois.kr] Expiration Date : 2013. 03. 02.
231 # [whois.nic.ir] expire-date: 2015-05-26
232 # [whois.nic.io] Expiry : 2017-01-25
233 } elsif ( $whois =~ m&(?:Expiry|Expiry Date|expire-date|Expire(?:d|s)? on|Valid[ -][Dd]ate|[Ee]xpiration [Dd]ate|Date of expiration|Renewal[- ][Dd]ate)(?:\.*|\s*):?\s+(\d{4})[/.-] ?(\d{2})[/.-] ?(\d{2})&si ) {
234 8 $rulenum = 2.2; $Y = $1; $m = $2; $d = $3;
235 # [whois.oleane.net] expires: 20030803
236 # [whois.nic.it] expire: 20051011
237 } elsif ( $whois =~ m/expires?:\s+(\d{4})(\d{2})(\d{2})/is ) {
238 1 $rulenum = 2.3; $Y = $1; $m = $2; $d = $3;
239 # [whois.ripe.net] .FI expires: 1.9.2007
240 # [whois.fi] .FI expires............: 1.9.2007
241 # [whois.rnids.rs] Expiration date: 15.09.2012 11:58:33
242 # [whois.dns.pt] Expiration Date (dd/mm/yyyy): 31/12/2013
243 # [whois.nic.im] Expiry Date: 28/12/2012 00:59:59
244 # [whois.isoc.org.il] validity: 15-08-2012
245 # [whois.register.bg] expires at: 08/01/2013 00:00:00 EET
246 } elsif ( $whois =~ m/(?:validity|Expiry Date|expires?(?:\.*)(?: at)?|expiration date(?: \(dd\/mm\/yyyy\))?):\s+(\d{1,2})[.\/-](\d{1,2})[.\/-](\d{4})/is ) {
247 1 $rulenum = 2.4; $Y = $3; $m = $2; $d = $1;
248 # [whois.dotster.com] Expires on: 12-DEC-05
249 # [whois for domain rosemount.com] Expires on..............: 26-Oct-15
250 # [whois.godaddy.com] Expires on: 02-Mar-16
251 } elsif ( $whois =~ m/Expires on\.*: (\d{2})-(\w{3})-(\d{2})/s ) {
252 1 $rulenum = 3; $d = $1; $b = $2; $y = $3;
253 # [whois.register.com] Expires on..............: Tue, Aug 04, 2009
254 # [whois.registrar.aol.com] Expires on..............: Oct 5 2002 12:00AM
255 # [whois.itsyourdomain.com] Record expires on March 06, 2011
256 # [whois.doregi.com] Record expires on.......: Oct 28, 2011
257 # [www.nic.ac] Expires : January 27 2019.
258 # [whois.isnic.is] expires: September 5 2012
259 } elsif ( $whois =~ m/(?:Record )?expires(?: on)?\.* ?:? +(?:\w{3}, )?(\w{3,9})\s{1,2}(\d{1,2}),? (\d{4})/is ) {
260 7 $rulenum = 4.1; $b = $1; $d = $2; $Y = $3;
261 # [whois.domainpeople.com] Expires on .............WED NOV 16 09:09:52 2011
262 # [whois.e-names.org] Expires after: Mon Jun 9 23:59:59 2003
263 # [whois.corporatedomains.com] Created on..............: Mon, Nov 12, 2007
264 } elsif ( $whois =~ m/(?:Created|Expires) (?:on|after)\s?\.*:?\s*\w{3},? (\w{3})\s{1,2}(\d{1,2})(?: \d{2}:\d{2}:\d{2})? (\d{4})?/is ) {
265 2 $rulenum = 4.2; $b = $1; $d = $2; $Y = $3;
266 # [whois.enom.com] Expiration date: Fri Sep 21 2012 13:45:09
267 # [whois.enom.com] Expires: Fri Sep 21 2012 13:45:09
268 # [whois.neulevel.biz] Domain Expiration Date: Fri Mar 26 23:59:59 GMT 2004
269 } elsif ( $whois =~ m/(?:Domain )?(?:Expires|Expiration Date):\s+\w{3} (\w{3}) (\d{2}) (?:\d{2}:\d{2}:\d{2} \w{3}(?:[-+]\d{2}:\d{2})? )(\d{4})/is ) {
270 0 $rulenum = 4.3; $b = $1; $d = $2; $Y = $3;
271 # [rs.domainbank.net] Record expires on 10-05-2003 11:21:25 AM
272 # [whois.psi-domains.com]
273 # [whois.namesecure.com] Expires on 10-09-2011
274 # [whois.catalog.com] Record Expires on 08-24-2011
275 } elsif ( $whois =~ m&expires.+?(\d{2})-(\d{2})-(\d{4})&is ) {
276 3 $rulenum = 5.1; $m = $1; $d = $2; $Y = $3;
277 # [whois.stargateinc.com] Expiration: 6/3/2004
278 # [whois.bookmyname.com] Expires on 11/26/2007 23:00:00
279 } elsif ( $whois =~ m&(?:Expiration|Expires on):? (\d{1,2})[-/](\d{1,2})[-/](\d{4})&is ) {
280 2 $rulenum = 5.2; $m = $1; $d = $2; $Y = $3;
281 # [whois.belizenic.bz] Expiration Date..: 15-01-2005 12:00:00
282 } elsif ( $whois =~ m&Expiration Date.+?(\d{2})-(\d{2})-(\d{4}) \d{2}:\d{2}:\d{2}&is ) {
283 0 $rulenum = 5.3; $d = $1; $m = $2; $Y = $3;
284 # edit for .uk domains: Adam McGreggor <cpan[...]amyl.org.uk>;
285 # kudos on a typo to <ganesh[...]urchin.earth.li>, via irc.mysociety.org
286 # [whois.nic.uk] Registered on: 21-Oct-2003
287 } elsif ( $whois =~ m&Registered on.+?(\d{2})-(\w{3})-(\d{4})&is ) {
288 0 $rulenum = 5.4; $d = $1; $b = $2; $Y = $3;
289 # [whois.nordnet.net] Record expires on 2010-Apr-03
290 # [whois.nic.nu] Record created on 1999-Apr-5.
291 # [whois.alldomains.com] Expires on..............: 2006-Jun-12
292 } elsif ( $whois =~ m/(?:Record |Domain )?expires on\.*:? (\d{4})-(\w{3})-(\d{1,2})/is ) {
293 3 $rulenum = 6; $Y = $1; $b = $2; $d = $3;
294 # [whois.enom.com] Expiration date: 09/21/03 13:45:09
295 } elsif ( $whois =~ m|Expiration date: (\d{2})/(\d{2})/(\d{2})|s ) {
296 1 $rulenum = 7; $m = $1; $d = $2; $y = $3;
297 } elsif ( $whois =~ m/Registered through- (\w{3}) (\w{3}) (\d{2}) (\d{4})/is ) {
298 0 $rulenum = 7.1; $b = $2; $d = $3; $Y = $4;
299 } elsif ( $whois =~ m|Expires: (\d{2})/(\d{2})/(\d{2})|is ) {
300 0 $rulenum = 7.2; $m = $1; $d = $2; $y = $3;
301 } elsif ( $whois =~ m|Registered through- (\d{2})/(\d{2})/(\d{2})|is ) {
302 0 $rulenum = 7.3; $m = $1; $d = $2; $y = $3;
303 # [whois.jprs.jp] [有効期限] 2006/12/31
304 } elsif ( $whois =~ m{ \[有効期限\] \s+ ( \d{4} ) / ( \d{2} ) / ( \d{2} )}sx ) {
305 1 $rulenum = 7.4; $Y = $1; $m = $2; $d = $3;
306 }
307 # [whois.ua] status: OK-UNTIL 20121122000000
308 elsif ( $whois =~ m|status:\s+OK-UNTIL (\d{4})(\d{2})(\d{2})\d{6}|s ) {
309 1 $rulenum = 7.5; $Y = $1; $m = $2; $d = $3;
310 }
311 # [whois.fi
312  
313  
314 60 ▶ unless ( $rulenum ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rulenum) { } 60 0 60
315 0 warn "Can't recognise expiration date format: $whois\n";
316 0 return;
317 }
318 else {
319 # warn "rulenum: $rulenum\n";
320 }
321  
322 60 my $fstr = '';
323 60 my $dstr = '';
324 60 ▶ $fstr .= $Y ? '%Y ' : '%y ';
Branch: 1 branch
BranchTrueFalseTotal
$Y ? : 58 2 60
325 60 ▶ $dstr .= $Y ? "$Y " : "$y ";
Branch: 1 branch
BranchTrueFalseTotal
$Y ? : 58 2 60
326  
327 60 ▶ if ( $b && length $b > 3 ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($b and length $b > 3) { } 3 57 60
elsif ($b and length $b == 3) { } 18 39 57
Condition100%3/3
$b and length $b > 3
!ll&&!rl&&r
39183
MC/DC100%2/2
$b and length $b > 3
$b length $b > 3
Truth table100%3/3
A and B
A= $bB= length $b > 3
ABresult
0X0
100
111
328 3 $fstr .= '%B ';
329 }
330 ▶ elsif ( $b && length $b == 3 ) {
Condition66%2/3
$b and length $b == 3
!ll&&!rl&&r
39018
MC/DC50%1/2
$b and length $b == 3
$b length $b == 3
Truth table66%2/3
A and B
A= $bB= length $b == 3
ABresult
0X0
100
111
331 18 $fstr .= '%b ';
332 }
333 else {
334 39 $fstr .= '%m ';
335 }
336  
337 60 ▶ $dstr .= $b ? "$b " : "$m ";
Branch: 1 branch
BranchTrueFalseTotal
$b ? : 21 39 60
338  
339 60 $fstr .= '%d';
340 60 $dstr .= $d;
341  
342 60 return decode_date( $dstr, $fstr );
343 }
344  
345 # extract creation date from whois output
346 sub _credate_int_cno {
347 16 ▶ my ( $whois ) = @_;
Subroutine _credate_int_cno: called CC=22 SCAR=34.9
348 16 ▶ return unless $whois;
Branch: 1 branch
BranchTrueFalseTotal
unless $whois 0 16 16
349  
350 # $Y - The year, including century
351 # $y - The year within century (0-99)
352 # $m - The month number (1-12)
353 # $b - The month name
354 # $d - The day of month (1-31)
355 16 my ( $rulenum, $Y, $y, $m, $b, $d );
356 # [whois.crsnic.net] Creation Date: 06-sep-2000
357 # [whois.afilias.info] Created On:31-Jul-2001 08:42:21 UTC
358 # [whois.enom.com] Creation date: 11 Jun 2004 14:22:48
359 # [whois for domain ibm.com] Record created on 19-Mar-1986.
360 # [whois.nic.me] Domain Create Date:28-Aug-2008 17:57:10 UTC
361 16 ▶ if ( $whois =~ m/Creat(?:ion|ed On|e)[^:]*?:?\s*(\d{2})[- ](\w{3})[- ](\d{4})/is ) {
Branch: 13 branches
BranchTrueFalseTotal
if ($whois =~ /Creat(?:ion|ed On|e)[^:]*?:?\s*(\d{2})[- ](\w{3})[- ](\d{4})/is) { } 2 14 16
elsif ($whois =~ m[(?:Creat.+?|Registration Date):?\s*?(\d{4})[/-](\d{1,2})[/-](\d{1,2})]is) { } 5 9 14
elsif ($whois =~ /(?:created|registered)(?:\.*):\s+(\d{1,2})[-.](\d{1,2})[-.](\d{4})/is) { } 2 7 9
elsif ($whois =~ /(?:created|registered):\s+(\d{4})[-.](\d{2})[-.](\d{2})/is) { } 0 7 7
elsif ($whois =~ /created?:\s+(\d{4})(\d{2})(\d{2})/is) { } 0 7 7
elsif ($whois =~ /changed:.+?(\d{4})(\d{2})(\d{2})/is) { } 0 7 7
elsif ($whois =~ /Creat.+?:?\s*(?:\w{3}, )?(\w{3,9})\s{1,2}(\d{1,2}),? (\d{4})/is) { } 3 4 7
elsif ($whois =~ /Regist.+?:\s*\w{3} (\w{3})\s+(\d{1,2}) (?:\d{2}:\d{2}:\d{2} )?(\d{4})/is) { } 1 3 4
elsif ($whois =~ /Registration.*?:\s+\w{3} (\w{3}) (\d{2}) (?:\d{2}:\d{2}:\d{2} \w{3}(?:[-+]\d{2}:\d{2})? )?(\d{4})/is) { } 1 2 3
elsif ($whois =~ /created.+?(\d{2})-(\d{2})-(\d{4})/is) { } 0 2 2
elsif ($whois =~ /Creation Date.+?(\d{2})-(\d{2})-(\d{4}) \d{2}:\d{2}:\d{2}/is) { } 0 2 2
elsif ($whois =~ m( \[\x{767b}\x{9332}\x{5e74}\x{6708}\x{65e5}\] \s+ ( \d{4} ) / ( \d{2} ) / ( \d{2} ) )sx) { } 1 1 2
elsif ($whois =~ /created:\s+0-UANIC (\d{4})(\d{2})(\d{2})\d{6}/s) { } 1 0 1
362 2 $rulenum = 1.2; $d = $1; $b = $2; $Y = $3;
363 # [whois.nic.name] Created On: 2002-02-08T14:56:54Z
364 # [whois.worldsite.ws] Domain created on 2002-10-29 03:54:36
365 # [..cn] Registration Date: 2003-03-19 08:06
366 } elsif ( $whois =~ m/(?:Creat.+?|Registration Date):?\s*?(\d{4})[\/-](\d{1,2})[\/-](\d{1,2})/is ) {
367 5 $rulenum = 2.1; $Y = $1; $m = $2; $d = $3;
368 # created: 16.12.2006
369 # created............: 16.12.2006
370 # created: 1.1.2006
371 } elsif ( $whois =~ m/(?:created|registered)(?:\.*):\s+(\d{1,2})[-.](\d{1,2})[-.](\d{4})/is ) {
372 2 $rulenum = 2.2; $Y = $3; $m = $2; $d = $1;
373 # [whois.org.ru] created: 2006.12.16
374 } elsif ( $whois =~ m/(?:created|registered):\s+(\d{4})[-.](\d{2})[-.](\d{2})/is ) {
375 0 $rulenum = 2.3; $Y = $1; $m = $2; $d = $3;
376 # [whois.nic.it] created: 20000421
377 } elsif ( $whois =~ m/created?:\s+(\d{4})(\d{2})(\d{2})/is ) {
378 0 $rulenum = 2.4; $Y = $1; $m = $2; $d = $3;
379 # [whois.relcom.net] changed: support@webnames.ru 20030815
380 } elsif ( $whois =~ m/changed:.+?(\d{4})(\d{2})(\d{2})/is ) {
381 0 $rulenum = 2.5; $Y = $1; $m = $2; $d = $3;
382 # [whois.tv] Record created on Feb 21 2001.
383 } elsif ( $whois =~ m/Creat.+?:?\s*(?:\w{3}, )?(\w{3,9})\s{1,2}(\d{1,2}),? (\d{4})/is ) {
384 3 $rulenum = 4.1; $b = $1; $d = $2; $Y = $3;
385 # [whois.dns.be] Registered: Wed Jan 17 2001
386 } elsif ( $whois =~ m/Regist.+?:\s*\w{3} (\w{3})\s+(\d{1,2}) (?:\d{2}:\d{2}:\d{2} )?(\d{4})/is ) {
387 1 $rulenum = 4.2; $b = $1; $d = $2; $Y = $3;
388 # [whois.whois.neulevel.biz] Domain Registration Date: Wed Mar 27 00:01:00 GMT 2002
389 } elsif ( $whois =~ m/Registration.*?:\s+\w{3} (\w{3}) (\d{2}) (?:\d{2}:\d{2}:\d{2} \w{3}(?:[-+]\d{2}:\d{2})? )?(\d{4})/is ) {
390 1 $rulenum = 4.3; $b = $1; $d = $2; $Y = $3;
391 } elsif ( $whois =~ m&created.+?(\d{2})-(\d{2})-(\d{4})&is ) {
392 0 $rulenum = 5.1; $m = $1; $d = $2; $Y = $3;
393 # [whois.belizenic.bz] Creation Date....: 15-01-2003 05:00:00
394 } elsif ( $whois =~ m&Creation Date.+?(\d{2})-(\d{2})-(\d{4}) \d{2}:\d{2}:\d{2}&is ) {
395 0 $rulenum = 5.3; $d = $1; $m = $2; $Y = $3;
396 # [whois.jprs.jp] [登録年月日] 2001/04/23
397 } elsif ( $whois =~ m{ \[登録年月日\] \s+ ( \d{4} ) / ( \d{2} ) / ( \d{2} ) }sx ) {
398 1 $rulenum = 7.4; $Y = $1; $m = $2; $d = $3;
399 # [whois.ua] created: 0-UANIC 20050104013013
400 } elsif ( $whois =~ m|created:\s+0-UANIC (\d{4})(\d{2})(\d{2})\d{6}|s ) {
401 1 $rulenum = 7.5; $Y = $1; $m = $2; $d = $3;
402 } else {
403 0 warn "Can't recognise creation date format\n";
404 0 return;
405 }
406  
407 16 my $fstr = '';
408 16 my $dstr = '';
409 16 ▶ $fstr .= $Y ? '%Y ' : '%y ';
Branch: 1 branch
BranchTrueFalseTotal
$Y ? : 16 0 16
410 16 ▶ $dstr .= $Y ? "$Y " : "$y ";
Branch: 1 branch
BranchTrueFalseTotal
$Y ? : 16 0 16
411  
412 16 ▶ if ( $b && length $b > 3 ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($b and length $b > 3) { } 1 15 16
elsif ($b and length $b == 3) { } 6 9 15
Condition100%3/3
$b and length $b > 3
!ll&&!rl&&r
961
MC/DC100%2/2
$b and length $b > 3
$b length $b > 3
Truth table100%3/3
A and B
A= $bB= length $b > 3
ABresult
0X0
100
111
413 1 $fstr .= '%B ';
414 }
415 ▶ elsif ( $b && length $b == 3 ) {
Condition66%2/3
$b and length $b == 3
!ll&&!rl&&r
906
MC/DC50%1/2
$b and length $b == 3
$b length $b == 3
Truth table66%2/3
A and B
A= $bB= length $b == 3
ABresult
0X0
100
111
416 6 $fstr .= '%b ';
417 }
418 else {
419 9 $fstr .= '%m ';
420 }
421  
422 16 ▶ $dstr .= $b ? "$b " : "$m ";
Branch: 1 branch
BranchTrueFalseTotal
$b ? : 7 9 16
423  
424 16 $fstr .= '%d';
425 16 $dstr .= $d;
426  
427 16 return decode_date( $dstr, $fstr );
428 }
429  
430 # extract creation/expiration dates from whois output for .ru, .su, .pp.ru, .net.ru, .org.ru, .рф domains
431 sub _dates_int_ru {
432 13 ▶ my ( $whois ) = @_;
Subroutine _dates_int_ru: called CC=27 SCAR=35.4
433 13 ▶ return unless $whois;
Branch: 1 branch
BranchTrueFalseTotal
unless $whois 0 13 13
434  
435 13 my ( $reg_till, $free_date, $created );
436  
437 13 ▶ $reg_till = $1 if $whois =~ /reg-till:\s*(.+?)\n/s ;
Branch: 1 branch
BranchTrueFalseTotal
if $whois =~ /reg-till:\s*(.+?)\n/s 5 8 13
438 13 ▶ $reg_till = $1 if $whois =~ /payed-till:\s*(.+?)\n/s ;
Branch: 1 branch
BranchTrueFalseTotal
if $whois =~ /payed-till:\s*(.+?)\n/s 0 13 13
439 13 ▶ $reg_till = $1 if $whois =~ /paid-till:\s*(.+?)\n/s ;
Branch: 1 branch
BranchTrueFalseTotal
if $whois =~ /paid-till:\s*(.+?)\n/s 2 11 13
440 13 ▶ $free_date = $1 if $whois =~ /free-date:\s*(.+?)\n/s ;
Branch: 1 branch
BranchTrueFalseTotal
if $whois =~ /free-date:\s*(.+?)\n/s 6 7 13
441 13 ▶ $created = $1 if $whois =~ /created:\s+(.+?)\n/s ;
Branch: 1 branch
BranchTrueFalseTotal
if $whois =~ /created:\s+(.+?)\n/s 7 6 13
442 13 ▶ $reg_till = $1 if $whois =~ /Delegated till\s*(.+?)\n/s;
Branch: 1 branch
BranchTrueFalseTotal
if $whois =~ /Delegated till\s*(.+?)\n/s 3 10 13
443  
444 13 my $format = '%Y-%m-%dT%H:%M:%SZ';
445 # OLD format date
446 13 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($created and $created =~ /\./ or $reg_till and $reg_till =~ /\./ or $free_date and $free_date =~ /\./) 2 9 11
Condition100%15/15
$created and $created =~ /\./ or $reg_till and $reg_till =~ /\./ or $free_date and $free_date =~ /\./
l!l&&r!l&&!r
319
$created and $created =~ /\./ or $reg_till and $reg_till =~ /\./
l!l&&r!l&&!r
2110
$created and $created =~ /\./
!ll&&!rl&&r
652
$reg_till and $reg_till =~ /\./
!ll&&!rl&&r
371
$free_date and $free_date =~ /\./
!ll&&!rl&&r
451
MC/DC66%4/6
$created and $created =~ /\./ or $reg_till and $reg_till =~ /\./ or $free_date and $free_date =~ /\./
$created $created =~ /\./ $reg_till $reg_till =~ /\./ $free_date $free_date =~ /\./
Truth table33%5/15
A and B or C and D or E and F
A= $createdB= $created =~ /\./C= $reg_tillD= $reg_till =~ /\./E= $free_dateF= $free_date =~ /\./
ABCDEFresult
11XXXX1
0X11XX1
1011XX1
0X0X111
0X10111
100X111
1010111
0X0X0X0
0X0X100
0X100X0
0X10100
100X0X0
100X100
10100X0
1010100
447 $created && $created =~ /\./
448 ||
449 $reg_till && $reg_till =~ /\./
450 ||
451 $free_date && $free_date =~ /\./
452 ) {
453  
454 4 $format = '%Y-%m-%d';
455  
456 4 ▶ $reg_till =~ tr/./-/ if $reg_till;
Branch: 1 branch
BranchTrueFalseTotal
if $reg_till 3 1 4
457 4 ▶ $free_date =~ tr/./-/ if $free_date;
Branch: 1 branch
BranchTrueFalseTotal
if $free_date 1 3 4
458 4 ▶ $created =~ tr/./-/ if $created;
Branch: 1 branch
BranchTrueFalseTotal
if $created 2 2 4
459 }
460  
461 13 ▶ if ( $created ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($created) 7 6 13
462 # Guess reg-till date
463 7 $created = decode_date( $created, $format );
464  
465 7 my $t = $created;
466  
467 7 ▶ if ( $t && !$reg_till && !$free_date ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t and not $reg_till and not $free_date) 0 7 7
Condition33%2/6
$t and not $reg_till and not $free_date
!ll&&!rl&&r
700
$t and not $reg_till
!ll&&!rl&&r
070
MC/DC0%0/3
$t and not $reg_till and not $free_date
$t not $reg_till not $free_date
Truth table25%1/4
A and not(B) and not(C)
A= $tB= not $reg_tillC= not $free_date
ABCresult
0XX0
10X0
1100
1111
468 0 $t += 0;
469 0 ▶ while ( $t < localtime() ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t < Net::Domain::ExpireDate::localtime()) 0 0 0
470 0 ▶ $t += ONE_YEAR + ( $t->is_leap_year() ? 1 : 0 );
Branch: 1 branch
BranchTrueFalseTotal
$t->is_leap_year ? : 0 0 0
471 }
472 0 $reg_till = $t->strftime( $format );
473 }
474 }
475  
476 13 ▶ unless ( $reg_till || $free_date ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($reg_till or $free_date) 0 13 13
Condition66%2/3
$reg_till or $free_date
l!l&&r!l&&!r
1030
MC/DC0%0/2
$reg_till or $free_date
$reg_till $free_date
Truth table66%2/3
A or B
A= $reg_tillB= $free_date
ABresult
1X1
011
000
477 0 warn "Can't obtain expiration date from ($reg_till)\n";
478 0 return;
479 }
480  
481 13 $reg_till = decode_date( $reg_till, $format );
482 13 $free_date = decode_date( $free_date, $format );
483  
484 13 ▶ if ( !$reg_till && $free_date ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $reg_till and $free_date) 3 10 13
Condition66%2/3
not $reg_till and $free_date
!ll&&!rl&&r
1003
MC/DC50%1/2
not $reg_till and $free_date
not $reg_till $free_date
Truth table66%2/3
not(A) and B
A= not $reg_tillB= $free_date
ABresult
0X0
100
111
485 3 $reg_till = $free_date - 33 * ONE_DAY;
486 }
487  
488 13 return $created, $reg_till, $free_date;
489 }
490  
491 sub _isin {
492 83 ▶ my ( $val, $arr ) = @_;
Subroutine _isin: called CC=4 SCAR=13.9
493 83 ▶ return 0 unless $arr;
Branch: 1 branch
BranchTrueFalseTotal
unless $arr 0 83 83
494  
495 83 for ( @$arr ) {
496 438 ▶ return 1 if $_ eq $val;
Branch: 1 branch
BranchTrueFalseTotal
if $_ eq $val 13 425 438
497 }
498  
499 70 return 0;
500 }
501  
502 sub import {
503 1 ▶ my $mypkg = shift;
Subroutine import: called CC=2 SCAR=6.9
504 1 my $callpkg = caller;
505  
506 1 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
507  
508 # export subs
509 1 *{ "$callpkg\::$_" } = \&{ "$mypkg\::$_" } for @EXPORT, @_;
510 }
511  
512  
513 1 1;
514 __END__
« blib/lib/Net/Domain/ExpireDate.pm ↑ Summary Build »