| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
=head1 NAME |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
XAO::DO::Web::CgiParam - Retrieves parameter from CGI environment |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
<%CgiParam param="username" default="test"%> |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
Displays CGI parameter. Arguments are: |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
name => parameter name |
|
14
|
|
|
|
|
|
|
default => default text |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=cut |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
############################################################################### |
|
19
|
|
|
|
|
|
|
package XAO::DO::Web::CgiParam; |
|
20
|
2
|
|
|
2
|
|
1758
|
use strict; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
58
|
|
|
21
|
2
|
|
|
2
|
|
11
|
use XAO::Utils; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
190
|
|
|
22
|
2
|
|
|
2
|
|
11
|
use XAO::Errors qw(XAO::DO::Web::CgiParam); |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
29
|
|
|
23
|
2
|
|
|
2
|
|
907
|
use base XAO::Objects->load(objname => 'Web::Page'); |
|
|
2
|
|
|
|
|
3174
|
|
|
|
2
|
|
|
|
|
17
|
|
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
our $VERSION='2.2'; |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub display ($;%) { |
|
28
|
19
|
|
|
19
|
1
|
24
|
my $self=shift; |
|
29
|
19
|
|
|
|
|
32
|
my $args=get_args(\@_); |
|
30
|
|
|
|
|
|
|
|
|
31
|
19
|
|
33
|
|
|
172
|
my $name=$args->{'name'} || $args->{'param'} || |
|
32
|
|
|
|
|
|
|
throw $self "- no 'param' and no 'name' given"; |
|
33
|
|
|
|
|
|
|
|
|
34
|
19
|
|
|
|
|
20
|
my $text; |
|
35
|
19
|
|
|
|
|
41
|
$text=$self->cgi->param($name); |
|
36
|
19
|
100
|
|
|
|
754
|
$text=$args->{'default'} unless defined $text; |
|
37
|
|
|
|
|
|
|
|
|
38
|
19
|
100
|
|
|
|
35
|
return unless defined $text; |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
# Preventing XSS attacks. Unless we have a 'dont_sanitize' parameter |
|
41
|
|
|
|
|
|
|
# angle brackets are removed from the output. |
|
42
|
|
|
|
|
|
|
# |
|
43
|
18
|
100
|
|
|
|
33
|
if(!$args->{'dont_sanitize'}) { |
|
44
|
17
|
|
|
|
|
45
|
$text=~s/[<>]/ /sg; |
|
45
|
|
|
|
|
|
|
} |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
# Zero bytes trigger a strange bug in at least some combinations of |
|
48
|
|
|
|
|
|
|
# Apache and XAO::Web. Repeated requests that send something like |
|
49
|
|
|
|
|
|
|
# ?foo=bar%00 that use CgiParam sometimes result in Apache hanging |
|
50
|
|
|
|
|
|
|
# even though processing is done. There is almost never a real need |
|
51
|
|
|
|
|
|
|
# to send a zero byte as an inline CGI parameter, so filtering it |
|
52
|
|
|
|
|
|
|
# out. |
|
53
|
|
|
|
|
|
|
# |
|
54
|
18
|
100
|
|
|
|
32
|
if(!$args->{'keep_zeros'}) { |
|
55
|
17
|
|
|
|
|
29
|
$text=~s/\x00/ /sg; |
|
56
|
|
|
|
|
|
|
} |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
# Trimming spaces |
|
59
|
|
|
|
|
|
|
# |
|
60
|
18
|
100
|
|
|
|
35
|
if(!$args->{'keep_spaces'}) { |
|
61
|
15
|
|
|
|
|
83
|
$text=~s/^\s*|\s*$//sg; |
|
62
|
|
|
|
|
|
|
} |
|
63
|
|
|
|
|
|
|
|
|
64
|
18
|
|
|
|
|
52
|
$self->textout($text); |
|
65
|
|
|
|
|
|
|
} |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
############################################################################### |
|
68
|
|
|
|
|
|
|
1; |
|
69
|
|
|
|
|
|
|
__END__ |