DRI/Protocol/Whois/Domain/common.pm

filter: Statementstmt 10.4% 10 / 96 Branchbran 0.0% 0 / 50 Conditioncond 0.0% 0 / 36 MC/DCmcdc 0.0% 0 / 24 Subroutinesub 33.3% 3 / 9 Podpod 0.0% 0 / 6 totaltotal 5.8% 13 / 221 CC 43 SCAR 59.1
CC
43
Cov
5%
epp_parse_contacts
702.0
epp_parse_dates
30.0
epp_parse_tel
30.0
CRAP 368.5
« DRI/Protocol/EPP/Extensions/NO/Host.pm ↑ Summary DRI/Protocol/EPP/Extensions/Validate.pm »
1 ## Domain Registry Interface, Whois common parse subroutines
2 ##
3 ## Copyright (c) 2007-2009,2012-2013 Patrick Mevzek <netdri@dotandco.com>. All rights reserved.
4 ##
5 ## This file is part of Net::DRI
6 ##
7 ## Net::DRI is free software; you can redistribute it and/or modify
8 ## it under the terms of the GNU General Public License as published by
9 ## the Free Software Foundation; either version 2 of the License, or
10 ## (at your option) any later version.
11 ##
12 ## See the LICENSE file that comes with this distribution for more details.
13 ####################################################################################################
14  
15 package Net::DRI::Protocol::Whois::Domain::common;
16  
17 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20 1 ▶use Net::DRI::Protocol::EPP::Core::Status;
Subroutine BEGIN: called CC=1 SCAR=0.0
21  
22 =pod
23  
24 =head1 NAME
25  
26 Net::DRI::Protocol::Whois::Domain::common - Whois commands (RFC3912) for Net::DRI
27  
28 =head1 DESCRIPTION
29  
30 Please see the README file for details.
31  
32 =head1 SUPPORT
33  
34 For now, support questions should be sent to:
35  
36 E<lt>netdri@dotandco.comE<gt>
37  
38 Please also see the SUPPORT file in the distribution.
39  
40 =head1 SEE ALSO
41  
42 E<lt>http://www.dotandco.com/services/software/Net-DRI/E<gt>
43  
44 =head1 AUTHOR
45  
46 Patrick Mevzek, E<lt>netdri@dotandco.comE<gt>
47  
48 =head1 COPYRIGHT
49  
50 Copyright (c) 2007-2009,2012-2013 Patrick Mevzek <netdri@dotandco.com>.
51 All rights reserved.
52  
53 This program is free software; you can redistribute it and/or modify
54 it under the terms of the GNU General Public License as published by
55 the Free Software Foundation; either version 2 of the License, or
56 (at your option) any later version.
57  
58 See the LICENSE file that comes with this distribution for more details.
59  
60 =cut
61  
62 ####################################################################################################
63  
64 sub epp_parse_registrars
65 0 ▶{
Subroutine epp_parse_registrars: not called CC=4 SCAR=30.0
Pod undocumented
66 0 my ($po,$domain,$rr,$rinfo)=@_;
67 0 my %t=('Sponsoring Registrar' => 'cl',
68 'Created By' => 'cr',
69 'Created by Registrar' => 'cr',
70 'Updated By' => 'up',
71 'Last Updated by Registrar' => 'up',
72 );
73  
74 0 ▶ while(my ($whois,$epp)=each(%t))
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %t) 0 0 0
75 {
76 0 ▶ next unless exists($rr->{$whois});
Branch: 1 branch
BranchTrueFalseTotal
unless exists $rr->{$whois} 0 0 0
77 0 my $s=$rr->{$whois}->[0];
78 0 ▶ if ($s=~m/^\s*(\S.+\S)\s+\((\S+)\)\s*$/)
Branch: 1 branch
BranchTrueFalseTotal
if ($s =~ /^\s*(\S.+\S)\s+\((\S+)\)\s*$/) { } 0 0 0
79 {
80 0 $rinfo->{domain}->{$domain}->{$epp.'ID'}=$2;
81 0 $rinfo->{domain}->{$domain}->{$epp.'Name'}=$1;
82 } else
83 {
84 0 $rinfo->{domain}->{$domain}->{$epp.'ID'}=$s;
85 }
86 }
87 0 return;
88 }
89  
90 sub epp_parse_dates
91 0 ▶{
Subroutine epp_parse_dates: not called CC=5 SCAR=34.0
Pod undocumented
92 0 my ($po,$domain,$rr,$rinfo)=@_;
93 0 my $strp=$po->build_strptime_parser(pattern => '%d-%b-%Y %T UTC', locale => 'en_US', time_zone => 'UTC');
94 0 $rinfo->{domain}->{$domain}->{crDate}=$strp->parse_datetime($rr->{'Created On'}->[0]);
95  
96 0 foreach my $k ('Updated On','Last Updated On')
97 {
98 0 ▶ next unless exists($rr->{$k});
Branch: 1 branch
BranchTrueFalseTotal
unless exists $rr->{$k} 0 0 0
99 0 $rinfo->{domain}->{$domain}->{upDate}=$strp->parse_datetime($rr->{$k}->[0]);
100 0 last;
101 }
102 0 foreach my $k ('Expires On','Expiration Date')
103 {
104 0 ▶ next unless exists($rr->{$k});
Branch: 1 branch
BranchTrueFalseTotal
unless exists $rr->{$k} 0 0 0
105 0 $rinfo->{domain}->{$domain}->{exDate}=$strp->parse_datetime($rr->{$k}->[0]);
106 0 last;
107 }
108 0 return;
109 }
110  
111 sub epp_parse_status
112 0 ▶{
Subroutine epp_parse_status: not called CC=4 SCAR=30.0
Pod undocumented
113 0 my ($po,$domain,$rr,$rinfo)=@_;
114 0 my @s;
115 0 ▶ if (exists($rr->{'Domain Status'}))
Branch: 2 branches
BranchTrueFalseTotal
if (exists $rr->{'Domain Status'}) { } 0 0 0
elsif (exists $rr->{'Status'}) { } 0 0 0
116 {
117 0 @s=map { my $s=$_; $s=~s/OK/ok/; $s; } @{$rr->{'Domain Status'}};
118 } elsif (exists($rr->{'Status'})) ## .ORG/.INFO/.MOBI/.CAT variation
119 {
120 0 @s=map { my $t=lc($_); $t=~s/ (.)/uc($1)/eg; $t; } @{$rr->{'Status'}};
121 }
122 0 ▶ $rinfo->{domain}->{$domain}->{status}=Net::DRI::Protocol::EPP::Core::Status->new(\@s) if @s;
Branch: 1 branch
BranchTrueFalseTotal
if @s 0 0 0
123 0 return;
124 }
125  
126 sub epp_parse_contacts
127 0 ▶{
Subroutine epp_parse_contacts: not called CC=26 SCAR=65.5
Pod undocumented
128 0 my ($po,$domain,$rr,$rinfo,$rh)=@_;
129 0 my $cs=$po->create_local_object('contactset');
130 0 ▶ while(my ($type,$whois)=each %$rh)
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %$rh) 0 0 0
131 {
132 0 my $c=$po->create_local_object('contact');
133 0 ▶ $c->srid($rr->{$whois.' ID'}->[0]) if (exists $rr->{$whois.' ID'} && length $rr->{$whois.' ID'}->[0]);
Branch: 1 branch
BranchTrueFalseTotal
if exists $$rr{$whois . ' ID'} and length $$rr{$whois . ' ID'}[0] 0 0 0
Condition0%0/3
exists $$rr{$whois . ' ID'} and length $$rr{$whois . ' ID'}[0]
!ll&&!rl&&r
000
MC/DC0%0/2
exists $$rr{$whois . ' ID'} and length $$rr{$whois . ' ID'}[0]
exists $$rr{$whois . ' ID'} length $$rr{$whois . ' ID'}[0]
Truth table0%0/3
A and B
A= exists $$rr{$whois . ' ID'}B= length $$rr{$whois . ' ID'}[0]
ABresult
0X0
100
111
134 0 ▶ $c->name($rr->{$whois.' Name'}->[0]) if (exists $rr->{$whois.' Name'} && length $rr->{$whois.' Name'}->[0]);
Branch: 1 branch
BranchTrueFalseTotal
if exists $$rr{$whois . ' Name'} and length $$rr{$whois . ' Name'}[0] 0 0 0
Condition0%0/3
exists $$rr{$whois . ' Name'} and length $$rr{$whois . ' Name'}[0]
!ll&&!rl&&r
000
MC/DC0%0/2
exists $$rr{$whois . ' Name'} and length $$rr{$whois . ' Name'}[0]
exists $$rr{$whois . ' Name'} length $$rr{$whois . ' Name'}[0]
Truth table0%0/3
A and B
A= exists $$rr{$whois . ' Name'}B= length $$rr{$whois . ' Name'}[0]
ABresult
0X0
100
111
135 0 ▶ $c->org($rr->{$whois.' Organization'}->[0]) if (exists $rr->{$whois.' Organization'} && length $rr->{$whois.' Organization'}->[0]);
Branch: 1 branch
BranchTrueFalseTotal
if exists $$rr{$whois . ' Organization'} and length $$rr{$whois . ' Organization'}[0] 0 0 0
Condition0%0/3
exists $$rr{$whois . ' Organization'} and length $$rr{$whois . ' Organization'}[0]
!ll&&!rl&&r
000
MC/DC0%0/2
exists $$rr{$whois . ' Organization'} and length $$rr{$whois . ' Organization'}[0]
exists $$rr{$whois . ' Organization'} length $$rr{$whois . ' Organization'}[0]
Truth table0%0/3
A and B
A= exists $$rr{$whois . ' Organization'}B= length $$rr{$whois . ' Organization'}[0]
ABresult
0X0
100
111
136 0 my @s;
137 0 foreach my $st (qw/Street Address/) ## 2nd form needed for .BIZ
138 {
139 0 my $k=$whois.' '.$st;
140 0 ▶ @s=map { $rr->{$k.$_}->[0] } grep { exists $rr->{$k.$_} && length $rr->{$k.$_}->[0] } (1..3);
Condition0%0/3
exists $$rr{$k . $_} && length $$rr{$k . $_}[0]
!ll&&!rl&&r
000
MC/DC0%0/2
exists $$rr{$k . $_} && length $$rr{$k . $_}[0]
exists $$rr{$k . $_} length $$rr{$k . $_}[0]
Truth table0%0/3
A && B
A= exists $$rr{$k . $_}B= length $$rr{$k . $_}[0]
ABresult
0X0
100
111
141 0 ▶ next unless @s;
Branch: 1 branch
BranchTrueFalseTotal
unless @s 0 0 0
142 0 $c->street(\@s);
143 0 last;
144 }
145 0 ▶ $c->city($rr->{$whois.' City'}->[0]) if (exists $rr->{$whois.' City'} && length $rr->{$whois.' City'}->[0]);
Branch: 1 branch
BranchTrueFalseTotal
if exists $$rr{$whois . ' City'} and length $$rr{$whois . ' City'}[0] 0 0 0
Condition0%0/3
exists $$rr{$whois . ' City'} and length $$rr{$whois . ' City'}[0]
!ll&&!rl&&r
000
MC/DC0%0/2
exists $$rr{$whois . ' City'} and length $$rr{$whois . ' City'}[0]
exists $$rr{$whois . ' City'} length $$rr{$whois . ' City'}[0]
Truth table0%0/3
A and B
A= exists $$rr{$whois . ' City'}B= length $$rr{$whois . ' City'}[0]
ABresult
0X0
100
111
146 0 ▶ $c->sp($rr->{$whois.' State/Province'}->[0]) if (exists $rr->{$whois.' State/Province'} && length $rr->{$whois.' State/Province'}->[0]);
Branch: 1 branch
BranchTrueFalseTotal
if exists $$rr{$whois . ' State/Province'} and length $$rr{$whois . ' State/Province'}[0] 0 0 0
Condition0%0/3
exists $$rr{$whois . ' State/Province'} and length $$rr{$whois . ' State/Province'}[0]
!ll&&!rl&&r
000
MC/DC0%0/2
exists $$rr{$whois . ' State/Province'} and length $$rr{$whois . ' State/Province'}[0]
exists $$rr{$whois . ' State/Province'} length $$rr{$whois . ' State/Province'}[0]
Truth table0%0/3
A and B
A= exists $$rr{$whois . ' State/Province'}B= length $$rr{$whois . ' State/Province'}[0]
ABresult
0X0
100
111
147 0 ▶ $c->pc($rr->{$whois.' Postal Code'}->[0]) if (exists $rr->{$whois.' Postal Code'} && length $rr->{$whois.' Postal Code'}->[0]);
Branch: 1 branch
BranchTrueFalseTotal
if exists $$rr{$whois . ' Postal Code'} and length $$rr{$whois . ' Postal Code'}[0] 0 0 0
Condition0%0/3
exists $$rr{$whois . ' Postal Code'} and length $$rr{$whois . ' Postal Code'}[0]
!ll&&!rl&&r
000
MC/DC0%0/2
exists $$rr{$whois . ' Postal Code'} and length $$rr{$whois . ' Postal Code'}[0]
exists $$rr{$whois . ' Postal Code'} length $$rr{$whois . ' Postal Code'}[0]
Truth table0%0/3
A and B
A= exists $$rr{$whois . ' Postal Code'}B= length $$rr{$whois . ' Postal Code'}[0]
ABresult
0X0
100
111
148 0 ▶ $c->cc($rr->{$whois.' Country'}->[0]) if (exists $rr->{$whois.' Country'} && length $rr->{$whois.' Country'}->[0]);
Branch: 1 branch
BranchTrueFalseTotal
if exists $$rr{$whois . ' Country'} and length $$rr{$whois . ' Country'}[0] 0 0 0
Condition0%0/3
exists $$rr{$whois . ' Country'} and length $$rr{$whois . ' Country'}[0]
!ll&&!rl&&r
000
MC/DC0%0/2
exists $$rr{$whois . ' Country'} and length $$rr{$whois . ' Country'}[0]
exists $$rr{$whois . ' Country'} length $$rr{$whois . ' Country'}[0]
Truth table0%0/3
A and B
A= exists $$rr{$whois . ' Country'}B= length $$rr{$whois . ' Country'}[0]
ABresult
0X0
100
111
149 0 my $t;
150 0 foreach my $st ('Phone','Phone Number') ## 2nd form needed for .BIZ
151 {
152 0 $t=epp_parse_tel($po,$rr,$whois.' '.$st);
153 0 ▶ next unless $t;
Branch: 1 branch
BranchTrueFalseTotal
unless $t 0 0 0
154 0 $c->voice($t);
155 0 last;
156 }
157 0 foreach my $st ('FAX','Facsimile Number') ## 2nd form needed for .BIZ
158 {
159 0 $t=epp_parse_tel($po,$rr,$whois.' '.$st);
160 0 ▶ next unless $t;
Branch: 1 branch
BranchTrueFalseTotal
unless $t 0 0 0
161 0 $c->fax($t);
162 0 last;
163 }
164 0 ▶ $c->email($rr->{$whois.' Email'}->[0]) if (exists $rr->{$whois.' Email'} && length $rr->{$whois.' Email'}->[0]);
Branch: 1 branch
BranchTrueFalseTotal
if exists $$rr{$whois . ' Email'} and length $$rr{$whois . ' Email'}[0] 0 0 0
Condition0%0/3
exists $$rr{$whois . ' Email'} and length $$rr{$whois . ' Email'}[0]
!ll&&!rl&&r
000
MC/DC0%0/2
exists $$rr{$whois . ' Email'} and length $$rr{$whois . ' Email'}[0]
exists $$rr{$whois . ' Email'} length $$rr{$whois . ' Email'}[0]
Truth table0%0/3
A and B
A= exists $$rr{$whois . ' Email'}B= length $$rr{$whois . ' Email'}[0]
ABresult
0X0
100
111
165 0 ▶ $cs->add($c,$type) if grep { length } ($c->srid(),$c->name(),$c->city(),$c->cc(),$c->email());
Branch: 1 branch
BranchTrueFalseTotal
if grep {length $_;} $c->srid, $c->name, $c->city, $c->cc, $c->email 0 0 0
166 }
167 0 $rinfo->{domain}->{$domain}->{contact}=$cs;
168 0 return;
169 }
170  
171 sub epp_parse_tel
172 0 ▶{
Subroutine epp_parse_tel: not called CC=5 SCAR=34.0
Pod undocumented
173 0 my ($po,$rr,$key)=@_;
174 0 ▶ return '' unless (exists($rr->{$key}) && $rr->{$key}->[0]);
Branch: 1 branch
BranchTrueFalseTotal
unless exists $rr->{$key} and $rr->{$key}[0] 0 0 0
Condition0%0/3
exists $rr->{$key} and $rr->{$key}[0]
!ll&&!rl&&r
000
MC/DC0%0/2
exists $rr->{$key} and $rr->{$key}[0]
exists $rr->{$key} $rr->{$key}[0]
Truth table0%0/3
A and B
A= exists $rr->{$key}B= $rr->{$key}[0]
ABresult
0X0
100
111
175 0 my $r=$rr->{$key}->[0];
176 0 ▶ $r.='x'.$rr->{$key.' Ext.'}->[0] if (exists($rr->{$key.' Ext.'}) && $rr->{$key.' Ext.'}->[0]);
Branch: 1 branch
BranchTrueFalseTotal
if exists $$rr{$key . ' Ext.'} and $$rr{$key . ' Ext.'}[0] 0 0 0
Condition0%0/3
exists $$rr{$key . ' Ext.'} and $$rr{$key . ' Ext.'}[0]
!ll&&!rl&&r
000
MC/DC0%0/2
exists $$rr{$key . ' Ext.'} and $$rr{$key . ' Ext.'}[0]
exists $$rr{$key . ' Ext.'} $$rr{$key . ' Ext.'}[0]
Truth table0%0/3
A and B
A= exists $$rr{$key . ' Ext.'}B= $$rr{$key . ' Ext.'}[0]
ABresult
0X0
100
111
177 0 return $r;
178 }
179  
180 sub epp_parse_ns
181 0 ▶{
Subroutine epp_parse_ns: not called CC=4 SCAR=30.0
Pod undocumented
182 0 my ($po,$domain,$rr,$rinfo)=@_;
183 0 ▶ return unless (exists($rr->{'Name Server'}));
Branch: 1 branch
BranchTrueFalseTotal
unless exists $rr->{"Name Server"} 0 0 0
184 0 ▶ my @ns=grep { defined($_) && $_ } @{$rr->{'Name Server'}};
Condition0%0/3
defined $_ && $_
!ll&&!rl&&r
000
MC/DC0%0/2
defined $_ && $_
defined $_ $_
Truth table0%0/3
A && B
A= defined $_B= $_
ABresult
0X0
100
111
185 0 ▶ $rinfo->{domain}->{$domain}->{ns}=$po->create_local_object('hosts')->set(@ns) if @ns;
Branch: 1 branch
BranchTrueFalseTotal
if @ns 0 0 0
186 0 return;
187 }
188  
189 ####################################################################################################
190 1 1;
« DRI/Protocol/EPP/Extensions/NO/Host.pm ↑ Summary DRI/Protocol/EPP/Extensions/Validate.pm »