DRI/Protocol/EPP/Util.pm

filter: Statementstmt 24.3% 54 / 222 Branchbran 8.4% 9 / 106 Conditioncond 2.6% 2 / 76 MC/DCmcdc 0.0% 0 / 40 Subroutinesub 39.1% 9 / 23 Podpod 0.0% 0 / 16 totaltotal 15.3% 74 / 483 CC 95 SCAR 44.7
CC
95
Cov
16%
build_postalinfo
210.0
build_ns
132.0
build_disclose
132.0
CRAP 87.7
« DRI/Protocol/EPP/Message.pm ↑ Summary DRI/Transport/HTTP/SOAPWSDL.pm »
1 ## Domain Registry Interface, EPP Protocol Utility functions
2 ##
3 ## Copyright (c) 2009,2010,2015,2018,2019 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::EPP::Util;
16  
17 5 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 5 ▶use feature 'state';
Subroutine BEGIN: called CC=1 SCAR=0.0
21  
22 5 ▶use Net::DRI::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
23 5 ▶use Net::DRI::Exception;
Subroutine BEGIN: called CC=1 SCAR=0.0
24  
25 ####################################################################################################
26  
27 sub parse_node_status
28 {
29 0 ▶ my ($node)=@_;
Subroutine parse_node_status: not called CC=1 SCAR=6.9
Pod undocumented
30 0 my %tmp=( name => $node->getAttribute('s') );
31 0 ($tmp{lang},$tmp{msg})=parse_node_msg($node);
32 0 return \%tmp;
33 }
34  
35 sub parse_node_msg
36 {
37 7 ▶ my ($node)=@_; ## eppcom:msgType
Subroutine parse_node_msg: called CC=3 SCAR=12.0
Pod undocumented
38 7 ▶ return (($node->getAttribute('lang') || 'en'),$node->textContent() || '');
Condition50%2/4
$node->getAttribute('lang') || 'en'
l!l
07
$node->textContent || ''
l!l
70
MC/DC0%0/1
$node->getAttribute('lang') || 'en'
$node->getAttribute('lang')
MC/DC0%0/1
$node->textContent || ''
$node->textContent
Truth table50%1/2
A
A= $node->getAttribute('lang')
Aresult
11
00
Truth table50%1/2
A
A= $node->textContent
Aresult
11
00
39 }
40  
41 ## Try to enhance parsing of common cases
42 sub parse_node_value
43 {
44 4 ▶ my ($n)=@_;
Subroutine parse_node_value: called CC=1 SCAR=0.0
Pod undocumented
45 4 my $t=$n->toString();
46 4 $t=~s!^<value(?:\s+xmlns:epp=["'][^"']+["'])?>(.+?)</value>$!$1!;
47 4 $t=~s/^\s+//;
48 4 $t=~s/\s+$//;
49 4 $t=~s!^<text>(.+)</text>$!$1!;
50 4 $t=~s!^<epp:undef\s*/>$!!;
51 4 return $t;
52 }
53  
54 sub parse_node_result
55 {
56 5 ▶ my ($node,$ns,$from)=@_;
Subroutine parse_node_result: called CC=8 SCAR=20.8
Pod undocumented
57 5 ▶ $from='eppcom' unless defined $from;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $from 5 0 5
58 5 my ($lang,$msg)=parse_node_msg($node->getChildrenByTagNameNS($ns,'msg')->get_node(1));
59  
60 5 my @i;
61 5 foreach my $el (Net::DRI::Util::xml_list_children($node)) ## <value> or <extValue> nodes, all optional
62 {
63 9 my ($name,$c)=@$el;
64 9 ▶ if ($name eq 'extValue')
Branch: 2 branches
BranchTrueFalseTotal
if ($name eq 'extValue') { } 2 7 9
elsif ($name eq 'value') { } 2 5 7
65 {
66 2 my @c=Net::DRI::Util::xml_list_children($c); ## we need to use that, instead of directly firstChild/lastChild because we want only element nodes, not whitespaces if there
67 2 my $c1=$c[0]->[1]; ## <value> node
68 2 my $c2=$c[-1]->[1]; ## <reason> node
69 2 my ($ll,$lt)=parse_node_msg($c2);
70 2 my $v=parse_node_value($c1);
71 2 ▶ my %info = ( from => $from.':extValue', type => $v=~m/^</ ? 'rawxml' : 'text');
Branch: 1 branch
BranchTrueFalseTotal
$v =~ /^</ ? : 2 0 2
72 2 ▶ if ($lt =~m/^\s*(\S+) not in login services\s*$/) # draft-gould-casanova-regext-unhandled-namespaces §3
Branch: 1 branch
BranchTrueFalseTotal
if ($lt =~ /^\s*(\S+) not in login services\s*$/) { } 1 1 2
73 {
74 1 $info{unhandled_namespace} = $1;
75 1 $v =~s!^<value>\s*!!;
76 1 $v =~s!\s*</value>$!!;
77 1 $info{unhandled_content} = $v;
78 } else
79 {
80 1 $info{lang} = $ll;
81 1 $info{reason} = $lt;
82 1 $info{message} = $v;
83 }
84 2 push @i, \%info;
85 } elsif ($name eq 'value')
86 {
87 2 my $v=parse_node_value($c);
88 2 ▶ push @i,{ from => $from.':value', type => $v=~m/^</ ? 'rawxml' : 'text', message => $v };
Branch: 1 branch
BranchTrueFalseTotal
$v =~ /^</ ? : 2 0 2
89 }
90 }
91  
92 5 return { code => $node->getAttribute('code'), message => $msg, lang => $lang, extra_info => \@i };
93 }
94  
95 ####################################################################################################
96  
97 sub domain_build_command
98 {
99 0 ▶ my ($msg,$command,$domain,$domainattr)=@_;
Subroutine domain_build_command: not called CC=8 SCAR=42.8
Pod undocumented
100 0 ▶ my @dom=ref $domain ? @$domain : ($domain);
Branch: 1 branch
BranchTrueFalseTotal
ref $domain ? : 0 0 0
101 0 ▶ Net::DRI::Exception->die(1,'protocol/EPP',2,'Domain name needed') unless @dom;
Branch: 1 branch
BranchTrueFalseTotal
unless @dom 0 0 0
102 0 foreach my $d (@dom)
103 {
104 0 ▶ Net::DRI::Exception->die(1,'protocol/EPP',2,'Domain name needed') unless defined $d && $d;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $d and $d 0 0 0
Condition0%0/3
defined $d and $d
!ll&&!rl&&r
000
MC/DC0%0/2
defined $d and $d
defined $d $d
Truth table0%0/3
A and B
A= defined $dB= $d
ABresult
0X0
100
111
105 0 ▶ Net::DRI::Exception->die(1,'protocol/EPP',10,'Invalid domain name: '.$d) unless Net::DRI::Util::xml_is_token($d,1,255);
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::xml_is_token($d, 1, 255) 0 0 0
106 }
107  
108 0 ▶ my $tcommand=ref $command ? $command->[0] : $command;
Branch: 1 branch
BranchTrueFalseTotal
ref $command ? : 0 0 0
109 0 $msg->command([$command,'domain:'.$tcommand, $msg->nsattrs('domain')]);
110  
111 0 my @d=map { ['domain:name',$_,$domainattr] } @dom;
112 0 return @d;
113 }
114  
115 sub domain_build_authinfo
116 {
117 0 ▶ my ($epp,$rauth,$isupdate)=@_;
Subroutine domain_build_authinfo: not called CC=7 SCAR=40.3
Pod undocumented
118 0 ▶ return ['domain:authInfo',['domain:null']] if ((! defined $rauth->{pw} || $rauth->{pw} eq '') && $epp->{usenullauth} && (defined($isupdate) && $isupdate));
Branch: 1 branch
BranchTrueFalseTotal
if !defined($rauth->{"pw"}) || $rauth->{"pw"} eq "" and $epp->{"usenullauth"} and (defined $isupdate and $isupdate) 0 0 0
Condition0%0/12
!defined($rauth->{"pw"}) || $rauth->{"pw"} eq "" and $epp->{"usenullauth"} and (defined $isupdate and $isupdate)
!ll&&!rl&&r
000
!defined($rauth->{"pw"}) || $rauth->{"pw"} eq "" and $epp->{"usenullauth"}
!ll&&!rl&&r
000
not defined $rauth->{"pw"} or $rauth->{"pw"} eq ""
l!l&&r!l&&!r
000
defined $isupdate and $isupdate
!ll&&!rl&&r
000
MC/DC0%0/5
!defined($rauth->{"pw"}) || $rauth->{"pw"} eq "" and $epp->{"usenullauth"} and (defined $isupdate and $isupdate)
not defined $rauth->{"pw"} $rauth->{"pw"} eq "" $epp->{"usenullauth"} defined $isupdate $isupdate
Truth table0%0/9
not(A) or B and C and D and E
A= not defined $rauth->{"pw"}B= $rauth->{"pw"} eq ""C= $epp->{"usenullauth"}D= defined $isupdateE= $isupdate
ABCDEresult
00XXX0
1X0XX0
010XX0
1X10X0
1X1100
0110X0
011100
1X1111
011111
119 0 ▶ return ['domain:authInfo',['domain:pw',$rauth->{pw},exists($rauth->{roid})? { 'roid' => $rauth->{roid} } : undef]];
Branch: 1 branch
BranchTrueFalseTotal
exists $rauth->{'roid'} ? : 0 0 0
120 }
121  
122 sub build_tel
123 {
124 0 ▶ my ($name,$tel)=@_;
Subroutine build_tel: not called CC=2 SCAR=17.9
Pod undocumented
125 0 ▶ if ($tel=~m/^(\S+)x(\S+)$/)
Branch: 1 branch
BranchTrueFalseTotal
if ($tel =~ /^(\S+)x(\S+)$/) { } 0 0 0
126 {
127 0 return [$name,$1,{x=>$2}];
128 } else
129 {
130 0 return [$name,$tel];
131 }
132 }
133  
134 sub parse_tel
135 {
136 0 ▶ my $node=shift;
Subroutine parse_tel: not called CC=3 SCAR=24.8
Pod undocumented
137 0 ▶ my $ext=$node->getAttribute('x') || '';
Condition0%0/2
$node->getAttribute('x') || ''
l!l
00
MC/DC0%0/1
$node->getAttribute('x') || ''
$node->getAttribute('x')
Truth table0%0/2
A
A= $node->getAttribute('x')
Aresult
11
00
138 0 my $num=$node->textContent();
139 0 ▶ $num.='x'.$ext if $ext;
Branch: 1 branch
BranchTrueFalseTotal
if $ext 0 0 0
140 0 return $num;
141 }
142  
143 sub build_period
144 {
145 0 ▶ my ($dtd,$ns)=@_;
Subroutine build_period: not called CC=9 SCAR=45.0
Pod undocumented
146 0 ▶ $ns//='domain';
Condition0%0/2
$ns //= "domain"
l!l
00
MC/DC0%0/1
$ns //= "domain"
$ns
Truth table0%0/2
A
A= $ns
Aresult
11
00
147 0 my ($y,$m)=$dtd->in_units('years','months'); ## all values are integral, but may be negative
148 0 ▶ ($y,$m)=(0,$m+12*$y) if ($y && $m);
Branch: 1 branch
BranchTrueFalseTotal
if $y and $m 0 0 0
Condition0%0/3
$y and $m
!ll&&!rl&&r
000
MC/DC0%0/2
$y and $m
$y $m
Truth table0%0/3
A and B
A= $yB= $m
ABresult
0X0
100
111
149 0 my ($v,$u);
150 0 ▶ if ($y)
Branch: 1 branch
BranchTrueFalseTotal
if ($y) { } 0 0 0
151 {
152 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('years must be between 1 and 99') unless ($y >= 1 && $y <= 99);
Branch: 1 branch
BranchTrueFalseTotal
unless $y >= 1 and $y <= 99 0 0 0
Condition0%0/3
$y >= 1 and $y <= 99
!ll&&!rl&&r
000
MC/DC0%0/2
$y >= 1 and $y <= 99
$y >= 1 $y <= 99
Truth table0%0/3
A and B
A= $y >= 1B= $y <= 99
ABresult
0X0
100
111
153 0 $v=$y;
154 0 $u='y';
155 } else
156 {
157 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('months must be between 1 and 99') unless ($m >= 1 && $m <= 99);
Branch: 1 branch
BranchTrueFalseTotal
unless $m >= 1 and $m <= 99 0 0 0
Condition0%0/3
$m >= 1 and $m <= 99
!ll&&!rl&&r
000
MC/DC0%0/2
$m >= 1 and $m <= 99
$m >= 1 $m <= 99
Truth table0%0/3
A and B
A= $m >= 1B= $m <= 99
ABresult
0X0
100
111
158 0 $v=$m;
159 0 $u='m';
160 }
161  
162 0 return [$ns.':period',$v,{'unit' => $u}];
163 }
164  
165 sub build_ns
166 {
167 0 ▶ my ($epp,$ns,$domain,$xmlns,$noip)=@_;
Subroutine build_ns: not called CC=11 SCAR=48.8
Pod undocumented
168  
169 0 my @d;
170 0 my $asattr=$epp->{hostasattr};
171  
172 0 ▶ if ($asattr)
Branch: 1 branch
BranchTrueFalseTotal
if ($asattr) { } 0 0 0
173 {
174 0 foreach my $i (1..$ns->count())
175 {
176 0 my ($n,$r4,$r6)=$ns->get_details($i);
177 0 my @h;
178 0 push @h,['domain:hostName',$n];
179 0 ▶ if ((($n=~m/\S+\.${domain}$/i) || (lc($n) eq lc($domain)) || ($asattr==2)) && (!defined($noip) || !$noip))
Branch: 1 branch
BranchTrueFalseTotal
if ($n =~ /\S+\.$domain$/i || lc $n eq lc $domain || $asattr == 2 and not defined $noip && $noip) 0 0 0
Condition0%0/12
$n =~ /\S+\.$domain$/i || lc $n eq lc $domain || $asattr == 2 and not defined $noip && $noip
!ll&&!rl&&r
000
$n =~ /\S+\.$domain$/i or lc $n eq lc $domain or $asattr == 2
l!l&&r!l&&!r
000
$n =~ /\S+\.$domain$/i or lc $n eq lc $domain
l!l&&r!l&&!r
000
defined $noip && $noip
!ll&&!rl&&r
000
MC/DC0%0/5
$n =~ /\S+\.$domain$/i || lc $n eq lc $domain || $asattr == 2 and not defined $noip && $noip
$n =~ /\S+\.$domain$/i lc $n eq lc $domain $asattr == 2 defined $noip $noip
Truth table0%0/10
A or B or C and not(D && E)
A= $n =~ /\S+\.$domain$/iB= lc $n eq lc $domainC= $asattr == 2D= defined $noipE= $noip
ABCDEresult
000XX0
1XX110
01X110
001110
1XX0X1
1XX101
01X0X1
01X101
0010X1
001101
180 {
181 0 ▶ push @h,map { ['domain:hostAddr',$_,{ip=>'v4'}] } @$r4 if @$r4;
Branch: 1 branch
BranchTrueFalseTotal
if @$r4 0 0 0
182 0 ▶ push @h,map { ['domain:hostAddr',$_,{ip=>'v6'}] } @$r6 if @$r6;
Branch: 1 branch
BranchTrueFalseTotal
if @$r6 0 0 0
183 }
184 0 push @d,['domain:hostAttr',@h];
185 }
186 } else
187 {
188 0 @d=map { ['domain:hostObj',$_] } $ns->get_names();
189 }
190  
191 0 ▶ $xmlns='domain' unless defined($xmlns);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $xmlns 0 0 0
192 0 return [$xmlns.':ns',@d];
193 }
194  
195 sub parse_ns ## RFC 4931 §1.1
196 {
197 0 ▶ my ($po,$node)=@_;
Subroutine parse_ns: not called CC=9 SCAR=45.0
Pod undocumented
198 0 my $ns=$po->create_local_object('hosts');
199  
200 0 foreach my $el (Net::DRI::Util::xml_list_children($node))
201 {
202 0 my ($name,$n)=@$el;
203 0 ▶ if ($name eq 'hostObj')
Branch: 2 branches
BranchTrueFalseTotal
if ($name eq 'hostObj') { } 0 0 0
elsif ($name eq 'hostAttr') { } 0 0 0
204 {
205 0 $ns->add($n->textContent());
206 } elsif ($name eq 'hostAttr')
207 {
208 0 my ($hostname,@ip4,@ip6);
209 0 foreach my $sel (Net::DRI::Util::xml_list_children($n))
210 {
211 0 my ($name2,$nn)=@$sel;
212 0 ▶ if ($name2 eq 'hostName')
Branch: 2 branches
BranchTrueFalseTotal
if ($name2 eq 'hostName') { } 0 0 0
elsif ($name2 eq 'hostAddr') { } 0 0 0
213 {
214 0 $hostname=$nn->textContent();
215 } elsif ($name2 eq 'hostAddr')
216 {
217 0 ▶ my $ip=$nn->getAttribute('ip') || 'v4';
Condition0%0/2
$nn->getAttribute('ip') || 'v4'
l!l
00
MC/DC0%0/1
$nn->getAttribute('ip') || 'v4'
$nn->getAttribute('ip')
Truth table0%0/2
A
A= $nn->getAttribute('ip')
Aresult
11
00
218 0 ▶ if ($ip eq 'v6')
Branch: 1 branch
BranchTrueFalseTotal
if ($ip eq 'v6') { } 0 0 0
219 {
220 0 push @ip6,$nn->textContent();
221 } else
222 {
223 0 push @ip4,$nn->textContent();
224 }
225 }
226 }
227 0 $ns->add($hostname,\@ip4,\@ip6,1);
228 }
229 }
230 0 return $ns;
231 }
232  
233 ## was Core::Domain::build_contact_noregistrant
234 sub build_core_contacts
235 {
236 0 ▶ my ($epp,$cs,$ns)=@_;
Subroutine build_core_contacts: not called CC=3 SCAR=24.8
Pod undocumented
237 0 my @d;
238 # All nonstandard contacts go into the extension section
239 0 my %r=map { $_ => 1 } $epp->core_contact_types();
240 0 foreach my $t (sort(grep { exists($r{$_}) } $cs->types()))
241 {
242 0 my @o=$cs->get($t);
243 0 ▶ push @d,map { [ ($ns // 'domain').':contact',$_->srid(),{'type'=>$t}] } @o;
Condition0%0/2
$ns // "domain"
l!l
00
MC/DC0%0/1
$ns // "domain"
$ns
Truth table0%0/2
A
A= $ns
Aresult
11
00
244 }
245 0 return @d;
246 }
247  
248 sub parse_postalinfo
249 {
250 0 ▶ my ($epp,$pi,$rcd)=@_;
Subroutine parse_postalinfo: not called CC=9 SCAR=45.0
Pod undocumented
251 0 my $type=$pi->getAttribute('type'); ## int or loc, mandatory in EPP !
252 0 ▶ $type=$epp->{defaulti18ntype} if (!defined($type) && defined($epp->{defaulti18ntype}));
Branch: 1 branch
BranchTrueFalseTotal
if not defined $type and defined $epp->{"defaulti18ntype"} 0 0 0
Condition0%0/3
not defined $type and defined $epp->{"defaulti18ntype"}
!ll&&!rl&&r
000
MC/DC0%0/2
not defined $type and defined $epp->{"defaulti18ntype"}
not defined $type defined $epp->{"defaulti18ntype"}
Truth table0%0/3
not(A) and B
A= not defined $typeB= defined $epp->{"defaulti18ntype"}
ABresult
0X0
100
111
253 0 state $index={'loc' => 0, 'int' => 1};
254 0 my $ti=$index->{$type};
255  
256 0 foreach my $el (Net::DRI::Util::xml_list_children($pi))
257 {
258 0 my ($name,$node)=@$el;
259 0 ▶ if ($name=~m/^(name|org)$/)
Branch: 2 branches
BranchTrueFalseTotal
if ($name =~ /^(name|org)$/) { } 0 0 0
elsif ($name eq 'addr') { } 0 0 0
260 {
261 0 $rcd->{$name}->[$ti]=$node->textContent();
262 } elsif ($name eq 'addr')
263 {
264 0 my @street;
265 0 foreach my $sel (Net::DRI::Util::xml_list_children($node))
266 {
267 0 my ($subname,$subnode)=@$sel;
268 0 ▶ if ($subname eq 'street')
Branch: 2 branches
BranchTrueFalseTotal
if ($subname eq 'street') { } 0 0 0
elsif ($subname =~ /^(city|sp|pc|cc)$/) { } 0 0 0
269 {
270 0 push @street,$subnode->textContent();
271 } elsif ($subname=~m/^(city|sp|pc|cc)$/)
272 {
273 0 $rcd->{$subname}->[$ti]=$subnode->textContent();
274 }
275 }
276 0 $rcd->{street}->[$ti]=\@street;
277 }
278 }
279 0 return;
280 }
281  
282 sub parse_disclose
283 {
284 0 ▶ my ($disclose)=@_;
Subroutine parse_disclose: not called CC=3 SCAR=24.8
Pod undocumented
285 0 my $flag=Net::DRI::Util::xml_parse_boolean($disclose->getAttribute('flag'));
286 0 my %r;
287 0 foreach my $el (Net::DRI::Util::xml_list_children($disclose))
288 {
289 0 my ($name,$node)=@$el;
290 0 ▶ if ($name=~m/^(name|org|addr)$/)
Branch: 1 branch
BranchTrueFalseTotal
if ($name =~ /^(name|org|addr)$/) { } 0 0 0
291 {
292 0 $r{$1.'_'.$node->getAttribute('type')}=$flag;
293 } else
294 {
295 0 $r{$name}=$flag;
296 }
297 }
298 0 return \%r;
299 }
300  
301 sub build_disclose
302 {
303 0 ▶ my ($d,$ns,@items)=@_;
Subroutine build_disclose: not called CC=11 SCAR=48.8
Pod undocumented
304 0 ▶ $ns//='contact';
Condition0%0/2
$ns //= "contact"
l!l
00
MC/DC0%0/1
$ns //= "contact"
$ns
Truth table0%0/2
A
A= $ns
Aresult
11
00
305 0 ▶ return () unless $d && ref $d eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless $d and ref $d eq "HASH" 0 0 0
Condition0%0/3
$d and ref $d eq "HASH"
!ll&&!rl&&r
000
MC/DC0%0/2
$d and ref $d eq "HASH"
$d ref $d eq "HASH"
Truth table0%0/3
A and B
A= $dB= ref $d eq "HASH"
ABresult
0X0
100
111
306 0 my %v=map { $_ => 1 } values %$d;
307 0 ▶ return () unless keys(%v)==1; ## 1 or 0 as values, not both at same time
Branch: 1 branch
BranchTrueFalseTotal
unless keys %v == 1 0 0 0
308 0 my @d;
309  
310 0 state $l1 = [ qw/name org addr/ ];
311 0 foreach my $item (@$l1)
312 {
313 0 ▶ if (exists $d->{$item})
Branch: 1 branch
BranchTrueFalseTotal
if (exists $d->{$item}) { } 0 0 0
314 {
315 0 push @d,[$ns.':'.$item,{type=>'int'}],[$ns.':name',{type=>'loc'}];
316 } else
317 {
318 0 ▶ push @d,[$ns.':'.$item,{type=>'int'}] if exists $d->{$item.'_int'};
Branch: 1 branch
BranchTrueFalseTotal
if exists $$d{$item . '_int'} 0 0 0
319 0 ▶ push @d,[$ns.':'.$item,{type=>'loc'}] if exists $d->{$item.'_loc'};
Branch: 1 branch
BranchTrueFalseTotal
if exists $$d{$item . '_loc'} 0 0 0
320 }
321 }
322 0 state $l2 = [ qw/voice fax email/ ];
323 0 foreach my $item (@$l2, @items)
324 {
325 0 ▶ push @d,[$ns.':'.$item] if exists $d->{$item};
Branch: 1 branch
BranchTrueFalseTotal
if exists $d->{$item} 0 0 0
326 }
327 0 return [$ns.':disclose',@d,{flag=>(keys(%v))[0]}];
328 }
329  
330 sub _do_locint
331 {
332 0 ▶ my ($rl,$ri,$contact,$ns,$what)=@_;
Subroutine _do_locint: not called CC=9 SCAR=45.0
333 0 my @tmp=$contact->$what();
334 0 ▶ return unless @tmp;
Branch: 1 branch
BranchTrueFalseTotal
unless @tmp 0 0 0
335 0 ▶ if ($what eq 'street')
Branch: 1 branch
BranchTrueFalseTotal
if ($what eq 'street') { } 0 0 0
336 {
337 0 ▶ if (defined($tmp[0])) { foreach (@{$tmp[0]}) { push @$rl,[$ns.':street',$_]; } };
Branch: 1 branch
BranchTrueFalseTotal
if (defined $tmp[0]) 0 0 0
338 0 ▶ if (defined($tmp[1])) { foreach (@{$tmp[1]}) { push @$ri,[$ns.':street',$_]; } };
Branch: 1 branch
BranchTrueFalseTotal
if (defined $tmp[1]) 0 0 0
339 } else
340 {
341 0 ▶ if (defined($tmp[0])) { push @$rl,[$ns.':'.$what,$tmp[0]]; }
Branch: 1 branch
BranchTrueFalseTotal
if (defined $tmp[0]) 0 0 0
342 0 ▶ if (defined($tmp[1])) { push @$ri,[$ns.':'.$what,$tmp[1]]; }
Branch: 1 branch
BranchTrueFalseTotal
if (defined $tmp[1]) 0 0 0
343 }
344 0 return;
345 }
346  
347 sub build_postalinfo
348 {
349 0 ▶ my ($contact,$v,$ns)=@_;
Subroutine build_postalinfo: not called CC=14 SCAR=53.5
Pod undocumented
350 0 ▶ $ns//='contact';
Condition0%0/2
$ns //= "contact"
l!l
00
MC/DC0%0/1
$ns //= "contact"
$ns
Truth table0%0/2
A
A= $ns
Aresult
11
00
351 0 my $hasloc=$contact->has_loc();
352 0 my $hasint=$contact->has_int();
353 0 ▶ if ($hasint && !$hasloc && (($v & 5) == $v))
Branch: 2 branches
BranchTrueFalseTotal
if ($hasint and not $hasloc and ($v & 5) == $v) { } 0 0 0
elsif ($hasloc and not $hasint and ($v & 6) == $v) { } 0 0 0
Condition0%0/6
$hasint and not $hasloc and ($v & 5) == $v
!ll&&!rl&&r
000
$hasint and not $hasloc
!ll&&!rl&&r
000
MC/DC0%0/3
$hasint and not $hasloc and ($v & 5) == $v
$hasint not $hasloc ($v & 5) == $v
Truth table0%0/4
A and not(B) and C
A= $hasintB= not $haslocC= ($v & 5) == $v
ABCresult
0XX0
10X0
1100
1111
354 {
355 0 $contact->int2loc();
356 0 $hasloc=1;
357 ▶ } elsif ($hasloc && !$hasint && (($v & 6) == $v))
Condition0%0/6
$hasloc and not $hasint and ($v & 6) == $v
!ll&&!rl&&r
000
$hasloc and not $hasint
!ll&&!rl&&r
000
MC/DC0%0/3
$hasloc and not $hasint and ($v & 6) == $v
$hasloc not $hasint ($v & 6) == $v
Truth table0%0/4
A and not(B) and C
A= $haslocB= not $hasintC= ($v & 6) == $v
ABCresult
0XX0
10X0
1100
1111
358 {
359 0 $contact->loc2int();
360 0 $hasint=1;
361 }
362  
363 0 my (@postl,@posti,@addrl,@addri);
364 0 _do_locint(\@postl,\@posti,$contact,$ns,'name');
365 0 _do_locint(\@postl,\@posti,$contact,$ns,'org');
366 0 _do_locint(\@addrl,\@addri,$contact,$ns,'street');
367 0 _do_locint(\@addrl,\@addri,$contact,$ns,'city');
368 0 _do_locint(\@addrl,\@addri,$contact,$ns,'sp');
369 0 _do_locint(\@addrl,\@addri,$contact,$ns,'pc');
370 0 _do_locint(\@addrl,\@addri,$contact,$ns,'cc');
371 0 ▶ push @postl,[$ns.':addr',@addrl] if @addrl;
Branch: 1 branch
BranchTrueFalseTotal
if @addrl 0 0 0
372 0 ▶ push @posti,[$ns.':addr',@addri] if @addri;
Branch: 1 branch
BranchTrueFalseTotal
if @addri 0 0 0
373  
374 0 my @d;
375 0 ▶ push @d,[$ns.':postalInfo',@postl,{type=>'loc'}] if (($v & 5) && $hasloc); ## loc+int OR loc
Branch: 1 branch
BranchTrueFalseTotal
if $v & 5 and $hasloc 0 0 0
Condition0%0/3
$v & 5 and $hasloc
!ll&&!rl&&r
000
MC/DC0%0/2
$v & 5 and $hasloc
$v & 5 $hasloc
Truth table0%0/3
A and B
A= $v & 5B= $hasloc
ABresult
0X0
100
111
376 0 ▶ push @d,[$ns.':postalInfo',@posti,{type=>'int'}] if (($v & 6) && $hasint); ## loc+int OR int
Branch: 1 branch
BranchTrueFalseTotal
if $v & 6 and $hasint 0 0 0
Condition0%0/3
$v & 6 and $hasint
!ll&&!rl&&r
000
MC/DC0%0/2
$v & 6 and $hasint
$v & 6 $hasint
Truth table0%0/3
A and B
A= $v & 6B= $hasint
ABresult
0X0
100
111
377  
378 0 return @d;
379 }
380  
381 ####################################################################################################
382 5 1;
383  
384 __END__
385  
386 =pod
387  
388 =head1 NAME
389  
390 Net::DRI::Protocol::EPP::Util - EPP Protocol Utility functions for Net::DRI
391  
392 =head1 DESCRIPTION
393  
394 Please see the README file for details.
395  
396 =head1 SUPPORT
397  
398 For now, support questions should be sent to:
399  
400 E<lt>netdri@dotandco.comE<gt>
401  
402 Please also see the SUPPORT file in the distribution.
403  
404 =head1 SEE ALSO
405  
406 E<lt>http://www.dotandco.com/services/software/Net-DRI/E<gt>
407  
408 =head1 AUTHOR
409  
410 Patrick Mevzek, E<lt>netdri@dotandco.comE<gt>
411  
412 =head1 COPYRIGHT
413  
414 Copyright (c) 2009,2010,2015,2018,2019 Patrick Mevzek <netdri@dotandco.com>.
415 All rights reserved.
416  
417 This program is free software; you can redistribute it and/or modify
418 it under the terms of the GNU General Public License as published by
419 the Free Software Foundation; either version 2 of the License, or
420 (at your option) any later version.
421  
422 See the LICENSE file that comes with this distribution for more details.
423  
424 =cut
« DRI/Protocol/EPP/Message.pm ↑ Summary DRI/Transport/HTTP/SOAPWSDL.pm »