Filename | /usr/local/src/github.com/foswiki/core/lib/Foswiki/Macros/URLPARAM.pm |
Statements | Executed 47 statements in 1.13ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
2 | 1 | 1 | 126µs | 331µs | URLPARAM | Foswiki::
2 | 1 | 1 | 46µs | 50µs | _handleURLPARAMValue | Foswiki::
1 | 1 | 1 | 34µs | 45µs | BEGIN@4.29 | Foswiki::
1 | 1 | 1 | 20µs | 47µs | BEGIN@5.30 | Foswiki::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | # See bottom of file for license and copyright information | ||||
2 | package Foswiki; | ||||
3 | |||||
4 | 2 | 56µs | 2 | 55µs | # spent 45µs (34+11) within Foswiki::BEGIN@4.29 which was called:
# once (34µs+11µs) by Foswiki::_expandMacroOnTopicRendering at line 4 # spent 45µs making 1 call to Foswiki::BEGIN@4.29
# spent 11µs making 1 call to strict::import |
5 | 2 | 908µs | 2 | 73µs | # spent 47µs (20+27) within Foswiki::BEGIN@5.30 which was called:
# once (20µs+27µs) by Foswiki::_expandMacroOnTopicRendering at line 5 # spent 47µs making 1 call to Foswiki::BEGIN@5.30
# spent 27µs making 1 call to warnings::import |
6 | |||||
7 | # spent 331µs (126+205) within Foswiki::URLPARAM which was called 2 times, avg 165µs/call:
# 2 times (126µs+205µs) by Foswiki::_expandMacroOnTopicRendering at line 3066 of /usr/local/src/github.com/foswiki/core/lib/Foswiki.pm, avg 165µs/call | ||||
8 | 28 | 110µs | my ( $this, $params ) = @_; | ||
9 | my $param = $params->{_DEFAULT} || ''; | ||||
10 | my $newLine = $params->{newline}; | ||||
11 | my $encode = $params->{encode} || 'safe'; | ||||
12 | my $multiple = $params->{multiple}; | ||||
13 | my $separator = $params->{separator}; | ||||
14 | my $default = $params->{default}; | ||||
15 | |||||
16 | $separator = "\n" unless ( defined $separator ); | ||||
17 | |||||
18 | my $value = ''; | ||||
19 | if ( $this->{request} ) { | ||||
20 | 2 | 20µs | if ( Foswiki::isTrue($multiple) ) { # spent 20µs making 2 calls to Foswiki::isTrue, avg 10µs/call | ||
21 | my @valueArray = $this->{request}->param($param); | ||||
22 | if (@valueArray) { | ||||
23 | |||||
24 | # join multiple values properly | ||||
25 | unless ( $multiple =~ m/^on$/i ) { | ||||
26 | my $item = ''; | ||||
27 | @valueArray = map { | ||||
28 | $item = $_; | ||||
29 | $_ = $multiple; | ||||
30 | $_ .= $item unless (s/\$item/$item/go); | ||||
31 | expandStandardEscapes($_) | ||||
32 | } @valueArray; | ||||
33 | } | ||||
34 | $value = join( | ||||
35 | $separator, | ||||
36 | map { | ||||
37 | _handleURLPARAMValue( $_, $newLine, $encode, $default ) | ||||
38 | } @valueArray | ||||
39 | ); | ||||
40 | } | ||||
41 | else { | ||||
42 | $value = $default; | ||||
43 | $value = '' unless defined $value; | ||||
44 | } | ||||
45 | } | ||||
46 | else { | ||||
47 | 2 | 135µs | $value = $this->{request}->param($param); # spent 135µs making 2 calls to Foswiki::Request::param, avg 68µs/call | ||
48 | 2 | 50µs | $value = # spent 50µs making 2 calls to Foswiki::_handleURLPARAMValue, avg 25µs/call | ||
49 | _handleURLPARAMValue( $value, $newLine, $encode, $default ); | ||||
50 | } | ||||
51 | } | ||||
52 | return $value; | ||||
53 | } | ||||
54 | |||||
55 | # spent 50µs (46+4) within Foswiki::_handleURLPARAMValue which was called 2 times, avg 25µs/call:
# 2 times (46µs+4µs) by Foswiki::URLPARAM at line 48, avg 25µs/call | ||||
56 | 14 | 52µs | my ( $value, $newLine, $encode, $default ) = @_; | ||
57 | |||||
58 | if ( defined $value ) { | ||||
59 | $value =~ s/\r?\n/$newLine/g if ( defined $newLine ); | ||||
60 | if ( $encode =~ /^entit(y|ies)$/i ) { | ||||
61 | $value = entityEncode($value); | ||||
62 | } | ||||
63 | elsif ( $encode =~ /^quotes?$/i ) { | ||||
64 | $value =~ | ||||
65 | s/\"/\\"/go; # escape quotes with backslash (Bugs:Item3383 fix) | ||||
66 | } | ||||
67 | elsif ( $encode =~ /^(off|none)$/i ) { | ||||
68 | |||||
69 | # no encoding | ||||
70 | } | ||||
71 | elsif ( $encode =~ /^url$/i ) { | ||||
72 | |||||
73 | # Legacy, see ENCODE | ||||
74 | #$value =~ s/\r*\n\r*/<br \/>/; | ||||
75 | $value = urlEncode($value); | ||||
76 | } | ||||
77 | else { # safe or default | ||||
78 | # entity encode ' " < > and % | ||||
79 | $value =~ s/([<>%'"])/'&#'.ord($1).';'/ge; | ||||
80 | } | ||||
81 | } | ||||
82 | unless ( defined $value ) { | ||||
83 | $value = $default; | ||||
84 | $value = '' unless defined $value; | ||||
85 | } | ||||
86 | |||||
87 | # Block expansion of %URLPARAM in the value to prevent recursion | ||||
88 | 2 | 4µs | $value =~ s/%URLPARAM{/%<nop>URLPARAM{/g; # spent 4µs making 2 calls to Foswiki::CORE:subst, avg 2µs/call | ||
89 | return $value; | ||||
90 | } | ||||
91 | |||||
92 | 1 | 6µs | 1; | ||
93 | __END__ |