DRI/Protocol/EPP/Extensions/IDN.pm

filter: Statementstmt 31.7% 13 / 41 Branchbran 0.0% 0 / 18 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 50.0% 4 / 8 Podpod 0.0% 0 / 4 totaltotal 23.9% 17 / 71 CC 11 SCAR 33.5
CC
11
Cov
22%
info_parse
42.0
create_build
42.0
register_commands
2.0
CRAP 28.4
« DRI/Protocol/EPP/Extensions/Nominet/Contact.pm ↑ Summary DRI/Protocol/EPP/Extensions/VeriSign/PollRGP.pm »
1 ## Domain Registry Interface, EPP IDN (draft-ietf-eppext-idnmap-02)
2 ##
3 ## Copyright (c) 2013,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::Extensions::IDN;
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::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 1 ▶use Net::DRI::Exception;
Subroutine BEGIN: called CC=1 SCAR=0.0
22  
23 ####################################################################################################
24  
25 sub register_commands
26 0 ▶{
Subroutine register_commands: not called CC=1 SCAR=6.9
Pod undocumented
27 0 my ($class,$version)=@_;
28 0 my %tmp=(
29 info => [ undef , \&info_parse ],
30 create => [ \&create_build, undef ],
31 );
32  
33 0 return { 'domain' => \%tmp };
34 }
35  
36 sub setup
37 0 ▶{
Subroutine setup: not called CC=1 SCAR=6.9
Pod undocumented
38 0 my ($class,$po,$version)=@_;
39 0 $po->ns({ 'idn' => 'urn:ietf:params:xml:ns:idn-1.0' });
40 0 return;
41 }
42  
43 ####################################################################################################
44  
45 sub info_parse
46 0 ▶{
Subroutine info_parse: not called CC=6 SCAR=37.4
Pod undocumented
47 0 my ($po,$otype,$oaction,$oname,$rinfo)=@_;
48 0 my $mes=$po->message();
49 0 ▶ return unless $mes->is_success();
Branch: 1 branch
BranchTrueFalseTotal
unless $mes->is_success 0 0 0
50  
51 0 my $data=$mes->get_extension('idn','data');
52 0 ▶ return unless defined $data;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $data 0 0 0
53  
54 0 foreach my $el (Net::DRI::Util::xml_list_children($data))
55 {
56 0 my ($name,$node)=@$el;
57 0 ▶ if ($name eq 'table')
Branch: 2 branches
BranchTrueFalseTotal
if ($name eq 'table') { } 0 0 0
elsif ($name eq 'uname') { } 0 0 0
58 {
59 0 $rinfo->{domain}->{$oname}->{idn_table}=$node->textContent();
60 } elsif ($name eq 'uname')
61 {
62 0 $rinfo->{domain}->{$oname}->{uname}=$node->textContent(); ## domain name in unicode NFC form
63 }
64 }
65  
66 0 return;
67 }
68  
69 sub create_build
70 0 ▶{
Subroutine create_build: not called CC=6 SCAR=37.4
Pod undocumented
71 0 my ($epp,$domain,$rd)=@_;
72  
73 0 ▶ return unless $domain=~m/^xn--/;
Branch: 1 branch
BranchTrueFalseTotal
unless $domain =~ /^xn--/ 0 0 0
74 0 ▶ Net::DRI::Exception::usererr_insufficient_parameters('For IDNs, an idn_table must be provided') unless Net::DRI::Util::has_key($rd,'idn_table');
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::has_key($rd, "idn_table") 0 0 0
75 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('idn_table must be of type XML schema token with at least 1 character') unless Net::DRI::Util::xml_is_token($rd->{idn_table},1);
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::xml_is_token($rd->{"idn_table"}, 1) 0 0 0
76 0 my @d;
77 0 push @d,['idn:table',$rd->{idn_table}];
78 0 ▶ if (Net::DRI::Util::has_key($rd,'uname'))
Branch: 1 branch
BranchTrueFalseTotal
if (Net::DRI::Util::has_key($rd, "uname")) 0 0 0
79 {
80 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('uname must be of type XML schema token from 1 to 255 characters') unless Net::DRI::Util::xml_is_token($rd->{uname},1,255);
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::xml_is_token($rd->{"uname"}, 1, 255) 0 0 0
81 0 push @d,['idn:uname',$rd->{uname}];
82 }
83  
84 0 $epp->message()->command_extension('idn' , ['data', @d]);
85  
86 0 return;
87 }
88  
89 ####################################################################################################
90 1 1;
91  
92 __END__
« DRI/Protocol/EPP/Extensions/Nominet/Contact.pm ↑ Summary DRI/Protocol/EPP/Extensions/VeriSign/PollRGP.pm »