line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CGI::Echo; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# Name: |
4
|
|
|
|
|
|
|
# CGI::Echo. |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
# Purpose: |
7
|
|
|
|
|
|
|
# Let students input data to a form, and echo it back to them. |
8
|
|
|
|
|
|
|
# |
9
|
|
|
|
|
|
|
# Documentation: |
10
|
|
|
|
|
|
|
# POD-style documentation is at the end. Extract it with pod2html.*. |
11
|
|
|
|
|
|
|
# |
12
|
|
|
|
|
|
|
# Note: |
13
|
|
|
|
|
|
|
# o tab = 4 spaces || die |
14
|
|
|
|
|
|
|
# |
15
|
|
|
|
|
|
|
# V 1.00 1-Oct-2002 |
16
|
|
|
|
|
|
|
# ----------------- |
17
|
|
|
|
|
|
|
# o Original version |
18
|
|
|
|
|
|
|
# |
19
|
|
|
|
|
|
|
# Author: |
20
|
|
|
|
|
|
|
# Ron Savage |
21
|
|
|
|
|
|
|
# http://savage.net.au/index.html |
22
|
|
|
|
|
|
|
|
23
|
1
|
|
|
1
|
|
21124
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
26
|
|
24
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
28
|
|
25
|
|
|
|
|
|
|
|
26
|
1
|
|
|
1
|
|
5
|
use Carp; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
1142
|
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
require 5.005_62; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
require Exporter; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
# Items to export into callers namespace by default. Note: do not export |
35
|
|
|
|
|
|
|
# names by default without a very good reason. Use EXPORT_OK instead. |
36
|
|
|
|
|
|
|
# Do not simply export all your public functions/methods/constants. |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
# This allows declaration use CGI::DBI ':all'; |
39
|
|
|
|
|
|
|
# If you do not need this, moving things directly into @EXPORT or @EXPORT_OK |
40
|
|
|
|
|
|
|
# will save memory. |
41
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( 'all' => [ qw() ] ); |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
our @EXPORT = qw(); |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
our $VERSION = '1.08'; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
# ----------------------------------------------- |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
# Preloaded methods go here. |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
# ----------------------------------------------- |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
# Encapsulated class data. |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
{ |
58
|
|
|
|
|
|
|
my(%_attr_data) = |
59
|
|
|
|
|
|
|
( |
60
|
|
|
|
|
|
|
_css => '', |
61
|
|
|
|
|
|
|
_q => '', |
62
|
|
|
|
|
|
|
_title => 'Echo Test', |
63
|
|
|
|
|
|
|
); |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub _clean_form_data |
66
|
|
|
|
|
|
|
{ |
67
|
0
|
|
|
0
|
|
|
my($self) = @_; |
68
|
0
|
|
|
|
|
|
$$self{'_data'} = {}; |
69
|
0
|
|
|
|
|
|
my(@param) = $$self{'_q'} -> param(); |
70
|
|
|
|
|
|
|
|
71
|
0
|
|
|
|
|
|
for my $field (@param) |
72
|
|
|
|
|
|
|
{ |
73
|
0
|
|
|
|
|
|
@{$$self{'_data'}{$field} } = $$self{'_q'} -> param($field); |
|
0
|
|
|
|
|
|
|
74
|
0
|
|
|
|
|
|
$$self{'_data'}{$field}[$_] = $self -> _clean_form_field($$self{'_data'}{$field}[$_], 200, 0) for (0 .. $#{$$self{'_data'}{$field} }); |
|
0
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
0
|
|
|
|
|
|
scalar keys %{$$self{'_data'} }; |
|
0
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
} # End of _clean_form_data. |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub _clean_form_field |
82
|
|
|
|
|
|
|
{ |
83
|
0
|
|
|
0
|
|
|
my($self, $data, $max_length, $integer) = @_; |
84
|
0
|
0
|
0
|
|
|
|
$data = '' if (! defined($data) || ($data !~ /^([^`\x00-\x1F\x7F-\x9F]+)$/) || (length($1) == 0) || (length($1) > $max_length) ); |
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
85
|
0
|
0
|
|
|
|
|
$data = '' if ($data =~ / |