Filename | /usr/local/lib/perl5/site_perl/URI/_idna.pm |
Statements | Executed 13 statements in 1.71ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 2.75ms | 4.71ms | BEGIN@9 | URI::_idna::
1 | 1 | 1 | 42µs | 56µs | BEGIN@6 | URI::_idna::
1 | 1 | 1 | 26µs | 146µs | BEGIN@10 | URI::_idna::
1 | 1 | 1 | 22µs | 22µs | BEGIN@15 | URI::_idna::
1 | 1 | 1 | 20µs | 59µs | BEGIN@7 | 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 | 64µs | 2 | 71µs | # spent 56µs (42+14) within URI::_idna::BEGIN@6 which was called:
# once (42µs+14µs) by IO::Socket::SSL::PublicSuffix::BEGIN@122 at line 6 # spent 56µs making 1 call to URI::_idna::BEGIN@6
# spent 14µs making 1 call to strict::import |
7 | 2 | 74µs | 2 | 98µs | # spent 59µs (20+38) within URI::_idna::BEGIN@7 which was called:
# once (20µs+38µs) by IO::Socket::SSL::PublicSuffix::BEGIN@122 at line 7 # spent 59µs making 1 call to URI::_idna::BEGIN@7
# spent 38µs making 1 call to warnings::import |
8 | |||||
9 | 2 | 296µs | 2 | 4.92ms | # spent 4.71ms (2.75+1.96) within URI::_idna::BEGIN@9 which was called:
# once (2.75ms+1.96ms) by IO::Socket::SSL::PublicSuffix::BEGIN@122 at line 9 # spent 4.71ms making 1 call to URI::_idna::BEGIN@9
# spent 206µs making 1 call to Exporter::import |
10 | 2 | 232µs | 2 | 267µs | # spent 146µs (26+120) within URI::_idna::BEGIN@10 which was called:
# once (26µs+120µs) by IO::Socket::SSL::PublicSuffix::BEGIN@122 at line 10 # spent 146µs making 1 call to URI::_idna::BEGIN@10
# spent 120µs making 1 call to Exporter::import |
11 | |||||
12 | 1 | 2µs | our $VERSION = '1.72'; | ||
13 | 1 | 31µs | $VERSION = eval $VERSION; # spent 6µs executing statements in string eval | ||
14 | |||||
15 | # spent 22µs within URI::_idna::BEGIN@15 which was called:
# once (22µ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 | 968µs | 1 | 22µs | } # spent 22µ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 |