diff options
| author | fukachan <fukachan> | 2001-11-09 00:07:10 +0000 |
|---|---|---|
| committer | fukachan <fukachan> | 2001-11-09 00:07:10 +0000 |
| commit | b7b674033eed3b6cd1f4b4c6a0bc6ee86eb0caf8 (patch) | |
| tree | 2dbd7c248cd62ab08299ba48860661fa667a349d | |
| parent | d84312329e65ca3ecb63ed578573e6e4132a505e (diff) | |
| download | fml8-b7b674033eed3b6cd1f4b4c6a0bc6ee86eb0caf8.tar.gz fml8-b7b674033eed3b6cd1f4b4c6a0bc6ee86eb0caf8.tar.bz2 fml8-b7b674033eed3b6cd1f4b4c6a0bc6ee86eb0caf8.zip | |
modified to fit FML::Process::CGI hierarchy
| -rw-r--r-- | fml/lib/FML/Process/CGI/Kernel.pm | 28 | ||||
| -rw-r--r-- | fml/lib/FML/Process/CGI/Param.pm | 65 |
2 files changed, 47 insertions, 46 deletions
diff --git a/fml/lib/FML/Process/CGI/Kernel.pm b/fml/lib/FML/Process/CGI/Kernel.pm index e0557ddf..369d21d5 100644 --- a/fml/lib/FML/Process/CGI/Kernel.pm +++ b/fml/lib/FML/Process/CGI/Kernel.pm @@ -4,7 +4,7 @@ # All rights reserved. This program is free software; you can # redistribute it and/or modify it under the same terms as Perl itself. # -# $FML: CGI.pm,v 1.18 2001/11/07 14:25:55 fukachan Exp $ +# $FML: Kernel.pm,v 1.1.1.1 2001/11/08 15:35:32 fukachan Exp $ # package FML::Process::CGI::Kernel; @@ -163,6 +163,32 @@ sub _makefml } +=head2 safe_param_xxx() + +get and filter param('xxx') via AUTOLOAD(). + +=cut + + +sub AUTOLOAD +{ + my ($curproc) = @_; + + return if $AUTOLOAD =~ /DESTROY/; + + my $comname = $AUTOLOAD; + $comname =~ s/.*:://; + + if ($comname =~ /^safe_param_(\S+)/) { + my $varname = $1; + return $curproc->safe_param($varname); + } + else { + croak("unknown method $comname"); + } +} + + =head1 AUTHOR Ken'ichi Fukamachi diff --git a/fml/lib/FML/Process/CGI/Param.pm b/fml/lib/FML/Process/CGI/Param.pm index c167dd2c..d5355cc6 100644 --- a/fml/lib/FML/Process/CGI/Param.pm +++ b/fml/lib/FML/Process/CGI/Param.pm @@ -4,7 +4,7 @@ # All rights reserved. This program is free software; you can # redistribute it and/or modify it under the same terms as Perl itself. # -# $FML: CGI.pm,v 1.18 2001/11/07 14:25:55 fukachan Exp $ +# $FML: Param.pm,v 1.1.1.1 2001/11/08 15:35:32 fukachan Exp $ # package FML::Process::CGI::Param; @@ -12,6 +12,9 @@ use strict; use vars qw(@ISA @EXPORT @EXPORT_OK $AUTOLOAD); use Carp; +# load standard CGI routines +use CGI qw/:standard/; + =head1 NAME FML::Process::CGI::Param - CGI basic functions @@ -36,6 +39,15 @@ It provides basic functions and flow. =cut +@EXPORT_OK = qw(safe_param %allow_regexp); + +my %allow_regexp = ( + 'address' => '[-a-z0-9_]@[-A-Z0-9\.]+', + 'ml_name' => '[-a-z0-9_]+', + 'method' => '[a-z]+', + 'user' => '[-a-z0-9_]+', + ); + # Descriptions: # Arguments: $self $args @@ -44,58 +56,21 @@ It provides basic functions and flow. # Return Value: none sub safe_param { - my ($key, $filter) = @_; - my $value = param($key); + my ($self, $key) = @_; + + if (defined param($key) && defined $allow_regexp{ $key }) { + my $value = param($key); + my $filter = $allow_regexp{ $key }; - if (defined $filter && defined $value) { if ($value =~ /^$filter$/) { return $value; } else { - return undef; - } - } - else { - return undef; - } -} - - -=head2 safe_param_xxx() - -get and filter param('xxx') via AUTOLOAD(). - -=cut - - -my %allow_regexp = ( - 'address' => '[-a-z0-9_]@[-A-Z0-9\.]+', - 'ml_name' => '[-a-z0-9_]+', - 'method' => '[a-z]+', - 'user' => '[-a-z0-9_]+', - ); - - -sub AUTOLOAD -{ - my ($curproc) = @_; - - return if $AUTOLOAD =~ /DESTROY/; - - my $comname = $AUTOLOAD; - $comname =~ s/.*:://; - - if ($comname =~ /^safe_param_(\S+)/) { - my $varname = $1; - - # diagnostic - unless (defined $allow_regexp{ $varname }) { - croak("no allow_regexp for $comname"); + croak("parameter $key has invalid character"); } - return safe_param($varname, $allow_regexp{ $varname }); } else { - croak("unknown method $comname"); + croak("parameter $key not permitted"); } } |
