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