summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfukachan <fukachan>2001-11-13 15:19:18 +0000
committerfukachan <fukachan>2001-11-13 15:19:18 +0000
commitf432cb60569a8490deabee78a5632cd31e438aaf (patch)
tree52e294955f4976cdbc78532c8a5f5e20fd8af15e
parent4f3fc40f9ad4fb16ab91c1230c252e8b76757fa5 (diff)
downloadfml8-f432cb60569a8490deabee78a5632cd31e438aaf.tar.gz
fml8-f432cb60569a8490deabee78a5632cd31e438aaf.tar.bz2
fml8-f432cb60569a8490deabee78a5632cd31e438aaf.zip
fix address regexp, define $command, modify error return way
-rw-r--r--fml/lib/FML/Process/CGI/Param.pm27
1 files changed, 17 insertions, 10 deletions
diff --git a/fml/lib/FML/Process/CGI/Param.pm b/fml/lib/FML/Process/CGI/Param.pm
index 1df39221..136f9c55 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: Param.pm,v 1.5 2001/11/11 23:34:00 fukachan Exp $
+# $FML: Param.pm,v 1.6 2001/11/13 03:43:07 fukachan Exp $
#
package FML::Process::CGI::Param;
@@ -43,9 +43,10 @@ It provides basic functions and flow.
my %allow_regexp =
(
- 'address' => '[-a-z0-9_]@[-A-Z0-9\.]+',
+ 'address' => '[-a-z0-9_]+\@[-A-Za-z0-9\.]+',
'ml_name' => '[-a-z0-9_]+',
'action' => '[-a-z_]+',
+ 'command' => '[-a-z_]+',
'user' => '[-a-z0-9_]+',
'article_id' => '\d+',
);
@@ -65,19 +66,25 @@ sub safe_param
{
my ($self, $key) = @_;
- if (defined param($key) && defined $allow_regexp{ $key }) {
- my $value = param($key);
- my $filter = $allow_regexp{ $key };
-
- if ($value =~ /^$filter$/) {
- return $value;
+ if (defined $allow_regexp{ $key }) {
+ if (defined param($key)) {
+ my $value = param($key);
+ my $filter = $allow_regexp{ $key };
+
+ if ($value =~ /^$filter$/) {
+ return $value;
+ }
+ else {
+ croak("CGI parameter $key has invalid character");
+ }
}
else {
- croak("parameter $key has invalid character");
+ # accpeptable but not defined, so return undef anyway
+ return undef;
}
}
else {
- croak("parameter $key not permitted under CGI");
+ croak("CGI parameter $key is undefined");
}
}