Filename | /usr/share/perl5/URI/_idna.pm |
Statements | Executed 77 statements in 840µs |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 1.45ms | 1.94ms | BEGIN@7 | URI::_idna::
8 | 1 | 1 | 51µs | 83µs | ToASCII | URI::_idna::
2 | 1 | 1 | 34µs | 118µs | encode | URI::_idna::
8 | 1 | 1 | 14µs | 14µs | check_size | URI::_idna::
1 | 1 | 1 | 12µs | 26µs | BEGIN@6 | URI::_idna::
1 | 1 | 1 | 10µs | 37µs | BEGIN@8 | URI::_idna::
8 | 1 | 1 | 10µs | 10µs | CORE:regcomp (opcode) | URI::_idna::
8 | 1 | 1 | 9µs | 9µs | CORE:match (opcode) | URI::_idna::
1 | 1 | 1 | 6µs | 6µs | BEGIN@10 | URI::_idna::
1 | 1 | 1 | 2µs | 2µs | CORE:qr (opcode) | URI::_idna::
0 | 0 | 0 | 0s | 0s | ToUnicode | URI::_idna::
0 | 0 | 0 | 0s | 0s | decode | 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 | 33µs | 2 | 41µs | # spent 26µs (12+14) within URI::_idna::BEGIN@6 which was called:
# once (12µs+14µs) by URI::_server::_host_escape at line 6 # spent 26µs making 1 call to URI::_idna::BEGIN@6
# spent 14µs making 1 call to strict::import |
7 | 2 | 125µs | 2 | 1.98ms | # spent 1.94ms (1.45+487µs) within URI::_idna::BEGIN@7 which was called:
# once (1.45ms+487µs) by URI::_server::_host_escape at line 7 # spent 1.94ms making 1 call to URI::_idna::BEGIN@7
# spent 41µs making 1 call to Exporter::import |
8 | 2 | 70µs | 2 | 64µs | # spent 37µs (10+27) within URI::_idna::BEGIN@8 which was called:
# once (10µs+27µs) by URI::_server::_host_escape at line 8 # spent 37µs making 1 call to URI::_idna::BEGIN@8
# spent 27µs making 1 call to Exporter::import |
9 | |||||
10 | # spent 6µs within URI::_idna::BEGIN@10 which was called:
# once (6µs+0s) by URI::_server::_host_escape at line 15 | ||||
11 | *URI::_idna::_ENV_::JOIN_LEAKS_UTF8_FLAGS = $] < 5.008_003 | ||||
12 | ? sub () { 1 } | ||||
13 | : sub () { 0 } | ||||
14 | 1 | 8µs | ; | ||
15 | 1 | 471µs | 1 | 6µs | } # spent 6µs making 1 call to URI::_idna::BEGIN@10 |
16 | |||||
17 | 1 | 10µs | 1 | 2µs | my $ASCII = qr/^[\x00-\x7F]*\z/; # spent 2µs making 1 call to URI::_idna::CORE:qr |
18 | |||||
19 | # spent 118µs (34+83) within URI::_idna::encode which was called 2 times, avg 59µs/call:
# 2 times (34µs+83µs) by URI::_server::_host_escape at line 25 of URI/_server.pm, avg 59µs/call | ||||
20 | 2 | 1µs | my $idomain = shift; | ||
21 | 2 | 7µs | my @labels = split(/\./, $idomain, -1); | ||
22 | 2 | 300ns | my @last_empty; | ||
23 | 2 | 2µs | push(@last_empty, pop @labels) if @labels > 1 && $labels[-1] eq ""; | ||
24 | 2 | 2µs | for (@labels) { | ||
25 | 8 | 12µs | 8 | 83µs | $_ = ToASCII($_); # spent 83µs making 8 calls to URI::_idna::ToASCII, avg 10µs/call |
26 | } | ||||
27 | |||||
28 | return eval 'join(".", @labels, @last_empty)' if URI::_idna::_ENV_::JOIN_LEAKS_UTF8_FLAGS; | ||||
29 | 2 | 8µs | return join(".", @labels, @last_empty); | ||
30 | } | ||||
31 | |||||
32 | sub decode { | ||||
33 | my $domain = shift; | ||||
34 | return join(".", map ToUnicode($_), split(/\./, $domain, -1)) | ||||
35 | } | ||||
36 | |||||
37 | sub nameprep { # XXX real implementation missing | ||||
38 | my $label = shift; | ||||
39 | $label = lc($label); | ||||
40 | return $label; | ||||
41 | } | ||||
42 | |||||
43 | # spent 14µs within URI::_idna::check_size which was called 8 times, avg 2µs/call:
# 8 times (14µs+0s) by URI::_idna::ToASCII at line 52, avg 2µs/call | ||||
44 | 8 | 2µs | my $label = shift; | ||
45 | 8 | 1µs | croak "Label empty" if $label eq ""; | ||
46 | 8 | 2µs | croak "Label too long" if length($label) > 63; | ||
47 | 8 | 16µs | return $label; | ||
48 | } | ||||
49 | |||||
50 | # spent 83µs (51+32) within URI::_idna::ToASCII which was called 8 times, avg 10µs/call:
# 8 times (51µs+32µs) by URI::_idna::encode at line 25, avg 10µs/call | ||||
51 | 8 | 2µs | my $label = shift; | ||
52 | 8 | 67µs | 24 | 32µs | return check_size($label) if $label =~ $ASCII; # spent 14µs making 8 calls to URI::_idna::check_size, avg 2µs/call
# spent 10µs making 8 calls to URI::_idna::CORE:regcomp, avg 1µs/call
# spent 9µs making 8 calls to URI::_idna::CORE:match, avg 1µs/call |
53 | |||||
54 | # Step 2: nameprep | ||||
55 | $label = nameprep($label); | ||||
56 | # Step 3: UseSTD3ASCIIRules is false | ||||
57 | # Step 4: try ASCII again | ||||
58 | return check_size($label) if $label =~ $ASCII; | ||||
59 | |||||
60 | # Step 5: Check ACE prefix | ||||
61 | if ($label =~ /^xn--/) { | ||||
62 | croak "Label starts with ACE prefix"; | ||||
63 | } | ||||
64 | |||||
65 | # Step 6: Encode with PUNYCODE | ||||
66 | $label = encode_punycode($label); | ||||
67 | |||||
68 | # Step 7: Prepend ACE prefix | ||||
69 | $label = "xn--$label"; | ||||
70 | |||||
71 | # Step 8: Check size | ||||
72 | return check_size($label); | ||||
73 | } | ||||
74 | |||||
75 | sub ToUnicode { | ||||
76 | my $label = shift; | ||||
77 | $label = nameprep($label) unless $label =~ $ASCII; | ||||
78 | return $label unless $label =~ /^xn--/; | ||||
79 | my $result = decode_punycode(substr($label, 4)); | ||||
80 | my $label2 = ToASCII($result); | ||||
81 | if (lc($label) ne $label2) { | ||||
82 | croak "IDNA does not round-trip: '\L$label\E' vs '$label2'"; | ||||
83 | } | ||||
84 | return $result; | ||||
85 | } | ||||
86 | |||||
87 | 1 | 3µs | 1; | ||
# spent 9µs within URI::_idna::CORE:match which was called 8 times, avg 1µs/call:
# 8 times (9µs+0s) by URI::_idna::ToASCII at line 52, avg 1µs/call | |||||
# spent 2µs within URI::_idna::CORE:qr which was called:
# once (2µs+0s) by URI::_server::_host_escape at line 17 | |||||
# spent 10µs within URI::_idna::CORE:regcomp which was called 8 times, avg 1µs/call:
# 8 times (10µs+0s) by URI::_idna::ToASCII at line 52, avg 1µs/call |