Filename | /var/www/foswiki11/lib/Foswiki/Macros/URLPARAM.pm |
Statements | Executed 68 statements in 684µs |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
3 | 1 | 1 | 64µs | 167µs | URLPARAM | Foswiki::
1 | 1 | 1 | 18µs | 34µs | BEGIN@4.45 | Foswiki::
3 | 1 | 1 | 15µs | 15µs | _handleURLPARAMValue | Foswiki::
1 | 1 | 1 | 11µs | 18µs | BEGIN@5.46 | 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 | 42µs | 2 | 50µs | # spent 34µs (18+16) within Foswiki::BEGIN@4.45 which was called:
# once (18µs+16µs) by Foswiki::_expandMacroOnTopicRendering at line 4 # spent 34µs making 1 call to Foswiki::BEGIN@4.45
# spent 16µs making 1 call to strict::import |
5 | 2 | 570µs | 2 | 25µs | # spent 18µs (11+7) within Foswiki::BEGIN@5.46 which was called:
# once (11µs+7µs) by Foswiki::_expandMacroOnTopicRendering at line 5 # spent 18µs making 1 call to Foswiki::BEGIN@5.46
# spent 7µs making 1 call to warnings::import |
6 | |||||
7 | # spent 167µs (64+103) within Foswiki::URLPARAM which was called 3 times, avg 56µs/call:
# 3 times (64µs+103µs) by Foswiki::_expandMacroOnTopicRendering at line 3160 of /var/www/foswiki11/lib/Foswiki.pm, avg 56µs/call | ||||
8 | 3 | 2µs | my ( $this, $params ) = @_; | ||
9 | 3 | 4µs | my $param = $params->{_DEFAULT} || ''; | ||
10 | 3 | 2µs | my $newLine = $params->{newline}; | ||
11 | 3 | 3µs | my $encode = $params->{encode} || 'safe'; | ||
12 | 3 | 2µs | my $multiple = $params->{multiple}; | ||
13 | 3 | 800ns | my $separator = $params->{separator}; | ||
14 | 3 | 900ns | my $default = $params->{default}; | ||
15 | |||||
16 | 3 | 1µs | $separator = "\n" unless ( defined $separator ); | ||
17 | |||||
18 | 3 | 900ns | my $value = ''; | ||
19 | 3 | 3µs | if ( $this->{request} ) { | ||
20 | 3 | 6µs | 3 | 8µs | if ( Foswiki::isTrue($multiple) ) { # spent 8µs making 3 calls to Foswiki::isTrue, avg 3µ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 | 3 | 7µs | 3 | 79µs | $value = $this->{request}->param($param); # spent 79µs making 3 calls to Foswiki::Request::param, avg 26µs/call |
48 | 3 | 8µs | 3 | 15µs | $value = # spent 15µs making 3 calls to Foswiki::_handleURLPARAMValue, avg 5µs/call |
49 | _handleURLPARAMValue( $value, $newLine, $encode, $default ); | ||||
50 | } | ||||
51 | } | ||||
52 | 3 | 10µs | return $value; | ||
53 | } | ||||
54 | |||||
55 | # spent 15µs within Foswiki::_handleURLPARAMValue which was called 3 times, avg 5µs/call:
# 3 times (15µs+0s) by Foswiki::URLPARAM at line 48, avg 5µs/call | ||||
56 | 3 | 3µs | my ( $value, $newLine, $encode, $default ) = @_; | ||
57 | |||||
58 | 3 | 800ns | 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 | 3 | 1µs | unless ( defined $value ) { | ||
83 | 3 | 700ns | $value = $default; | ||
84 | 3 | 1µs | $value = '' unless defined $value; | ||
85 | } | ||||
86 | |||||
87 | # Block expansion of %URLPARAM in the value to prevent recursion | ||||
88 | 3 | 1µs | $value =~ s/%URLPARAM{/%<nop>URLPARAM{/g; | ||
89 | 3 | 12µs | return $value; | ||
90 | } | ||||
91 | |||||
92 | 1 | 3µs | 1; | ||
93 | __END__ |