Filename | /usr/local/lib/perl5/site_perl/URI/_idna.pm |
Statements | Executed 13 statements in 1.69ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 2.74ms | 4.66ms | BEGIN@9 | URI::_idna::
1 | 1 | 1 | 43µs | 55µs | BEGIN@6 | URI::_idna::
1 | 1 | 1 | 25µs | 155µs | BEGIN@10 | URI::_idna::
1 | 1 | 1 | 18µs | 56µs | BEGIN@7 | URI::_idna::
1 | 1 | 1 | 18µs | 18µs | BEGIN@15 | URI::_idna::
1 | 1 | 1 | 4µs | 4µs | CORE:qr (opcode) | URI::_idna::
0 | 0 | 0 | 0s | 0s | ToASCII | URI::_idna::
0 | 0 | 0 | 0s | 0s | ToUnicode | URI::_idna::
0 | 0 | 0 | 0s | 0s | check_size | URI::_idna::
0 | 0 | 0 | 0s | 0s | decode | URI::_idna::
0 | 0 | 0 | 0s | 0s | encode | URI::_idna::
0 | 0 | 0 | 0s | 0s | nameprep | URI::_idna::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package URI::_idna; | ||||
2 | |||||
3 | # This module implements the RFCs 3490 (IDNA) and 3491 (Nameprep) | ||||
4 | # based on Python-2.6.4/Lib/encodings/idna.py | ||||
5 | |||||
6 | 2 | 68µs | 2 | 67µs | # spent 55µs (43+12) within URI::_idna::BEGIN@6 which was called:
# once (43µs+12µs) by IO::Socket::SSL::PublicSuffix::BEGIN@122 at line 6 # spent 55µs making 1 call to URI::_idna::BEGIN@6
# spent 12µs making 1 call to strict::import |
7 | 2 | 102µs | 2 | 93µs | # spent 56µs (18+37) within URI::_idna::BEGIN@7 which was called:
# once (18µs+37µs) by IO::Socket::SSL::PublicSuffix::BEGIN@122 at line 7 # spent 56µs making 1 call to URI::_idna::BEGIN@7
# spent 37µs making 1 call to warnings::import |
8 | |||||
9 | 2 | 275µs | 2 | 4.86ms | # spent 4.66ms (2.74+1.92) within URI::_idna::BEGIN@9 which was called:
# once (2.74ms+1.92ms) by IO::Socket::SSL::PublicSuffix::BEGIN@122 at line 9 # spent 4.66ms making 1 call to URI::_idna::BEGIN@9
# spent 204µs making 1 call to Exporter::import |
10 | 2 | 207µs | 2 | 286µs | # spent 155µs (25+131) within URI::_idna::BEGIN@10 which was called:
# once (25µs+131µs) by IO::Socket::SSL::PublicSuffix::BEGIN@122 at line 10 # spent 155µs making 1 call to URI::_idna::BEGIN@10
# spent 131µs making 1 call to Exporter::import |
11 | |||||
12 | 1 | 2µs | our $VERSION = '1.72'; | ||
13 | 1 | 39µs | $VERSION = eval $VERSION; # spent 6µs executing statements in string eval | ||
14 | |||||
15 | # spent 18µs within URI::_idna::BEGIN@15 which was called:
# once (18µs+0s) by IO::Socket::SSL::PublicSuffix::BEGIN@122 at line 20 | ||||
16 | *URI::_idna::_ENV_::JOIN_LEAKS_UTF8_FLAGS = "$]" < 5.008_003 | ||||
17 | ? sub () { 1 } | ||||
18 | : sub () { 0 } | ||||
19 | 1 | 14µs | ; | ||
20 | 1 | 953µs | 1 | 18µs | } # spent 18µs making 1 call to URI::_idna::BEGIN@15 |
21 | |||||
22 | 1 | 19µs | 1 | 4µs | my $ASCII = qr/^[\x00-\x7F]*\z/; # spent 4µs making 1 call to URI::_idna::CORE:qr |
23 | |||||
24 | sub encode { | ||||
25 | my $idomain = shift; | ||||
26 | my @labels = split(/\./, $idomain, -1); | ||||
27 | my @last_empty; | ||||
28 | push(@last_empty, pop @labels) if @labels > 1 && $labels[-1] eq ""; | ||||
29 | for (@labels) { | ||||
30 | $_ = ToASCII($_); | ||||
31 | } | ||||
32 | |||||
33 | return eval 'join(".", @labels, @last_empty)' if URI::_idna::_ENV_::JOIN_LEAKS_UTF8_FLAGS; | ||||
34 | return join(".", @labels, @last_empty); | ||||
35 | } | ||||
36 | |||||
37 | sub decode { | ||||
38 | my $domain = shift; | ||||
39 | return join(".", map ToUnicode($_), split(/\./, $domain, -1)) | ||||
40 | } | ||||
41 | |||||
42 | sub nameprep { # XXX real implementation missing | ||||
43 | my $label = shift; | ||||
44 | $label = lc($label); | ||||
45 | return $label; | ||||
46 | } | ||||
47 | |||||
48 | sub check_size { | ||||
49 | my $label = shift; | ||||
50 | croak "Label empty" if $label eq ""; | ||||
51 | croak "Label too long" if length($label) > 63; | ||||
52 | return $label; | ||||
53 | } | ||||
54 | |||||
55 | sub ToASCII { | ||||
56 | my $label = shift; | ||||
57 | return check_size($label) if $label =~ $ASCII; | ||||
58 | |||||
59 | # Step 2: nameprep | ||||
60 | $label = nameprep($label); | ||||
61 | # Step 3: UseSTD3ASCIIRules is false | ||||
62 | # Step 4: try ASCII again | ||||
63 | return check_size($label) if $label =~ $ASCII; | ||||
64 | |||||
65 | # Step 5: Check ACE prefix | ||||
66 | if ($label =~ /^xn--/) { | ||||
67 | croak "Label starts with ACE prefix"; | ||||
68 | } | ||||
69 | |||||
70 | # Step 6: Encode with PUNYCODE | ||||
71 | $label = encode_punycode($label); | ||||
72 | |||||
73 | # Step 7: Prepend ACE prefix | ||||
74 | $label = "xn--$label"; | ||||
75 | |||||
76 | # Step 8: Check size | ||||
77 | return check_size($label); | ||||
78 | } | ||||
79 | |||||
80 | sub ToUnicode { | ||||
81 | my $label = shift; | ||||
82 | $label = nameprep($label) unless $label =~ $ASCII; | ||||
83 | return $label unless $label =~ /^xn--/; | ||||
84 | my $result = decode_punycode(substr($label, 4)); | ||||
85 | my $label2 = ToASCII($result); | ||||
86 | if (lc($label) ne $label2) { | ||||
87 | croak "IDNA does not round-trip: '\L$label\E' vs '$label2'"; | ||||
88 | } | ||||
89 | return $result; | ||||
90 | } | ||||
91 | |||||
92 | 1 | 8µs | 1; | ||
# spent 4µs within URI::_idna::CORE:qr which was called:
# once (4µs+0s) by IO::Socket::SSL::PublicSuffix::BEGIN@122 at line 22 |