summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfukachan <fukachan>2001-11-11 23:33:59 +0000
committerfukachan <fukachan>2001-11-11 23:33:59 +0000
commitd9a188cae87f737260d07e3c3c942c8295c6dec8 (patch)
treebe72689be45efd2080e22e1b10e476fd8a47f028
parente98db4e30dd9e4f4bc5a6ec6b2af8f622aa7e244 (diff)
downloadfml8-d9a188cae87f737260d07e3c3c942c8295c6dec8.tar.gz
fml8-d9a188cae87f737260d07e3c3c942c8295c6dec8.tar.bz2
fml8-d9a188cae87f737260d07e3c3c942c8295c6dec8.zip
move "function to get paramlist" to FML::Process::CGI::Param module
implement safe_pramlist\d+_\S+() via AUTOLOAD()
-rw-r--r--fml/lib/FML/CGI/ThreadTrack.pm19
-rw-r--r--fml/lib/FML/Process/CGI/Kernel.pm12
-rw-r--r--fml/lib/FML/Process/CGI/Param.pm54
3 files changed, 61 insertions, 24 deletions
diff --git a/fml/lib/FML/CGI/ThreadTrack.pm b/fml/lib/FML/CGI/ThreadTrack.pm
index 92ca9cbf..088f006f 100644
--- a/fml/lib/FML/CGI/ThreadTrack.pm
+++ b/fml/lib/FML/CGI/ThreadTrack.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: ThreadTrack.pm,v 1.4 2001/11/11 11:12:27 fukachan Exp $
+# $FML: ThreadTrack.pm,v 1.5 2001/11/11 13:37:40 fukachan Exp $
#
package FML::CGI::ThreadTrack;
@@ -90,8 +90,6 @@ sub run_cgi
my $thread = new Mail::ThreadTrack $ttargs;
$thread->set_mode('html');
- # for (param()) { print "PARAM(debug): $_ => ", param($_), "<BR>\n";}
-
if ($action eq 'list') {
$thread->summary();
}
@@ -103,15 +101,12 @@ sub run_cgi
elsif ($action eq 'change_status') {
# fmlthread.cgi is for administorator, so you can change status.
if ($myname eq 'fmlthread.cgi') {
- my (@id);
- for my $param (param()) {
- my $req = param($param);
- if ($req eq 'closed') {
- if ($param =~ /^change_status\.(\S+)\/(\d+)$/) {
- my $tid = $thread->_create_thread_id_strings($2);
- print "closed $tid\n"; print br;
- $thread->close($tid);
- }
+ my $list = $curproc->safe_paramlist2_threadcgi_change_status();
+ for my $param (@$list) {
+ my ($ml, $id, $value) = @$param;
+ if ($value eq 'closed') {
+ my $tid = $thread->_create_thread_id_strings($id);
+ $thread->close($tid);
}
}
}
diff --git a/fml/lib/FML/Process/CGI/Kernel.pm b/fml/lib/FML/Process/CGI/Kernel.pm
index 9fa34bb1..ad34b951 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: Kernel.pm,v 1.4 2001/11/11 01:08:40 fukachan Exp $
+# $FML: Kernel.pm,v 1.5 2001/11/11 11:04:58 fukachan Exp $
#
package FML::Process::CGI::Kernel;
@@ -155,9 +155,13 @@ sub AUTOLOAD
my $comname = $AUTOLOAD;
$comname =~ s/.*:://;
- if ($comname =~ /^safe_param_(\S+)/) {
- my $varname = $1;
- return $curproc->safe_param($varname);
+ if ($comname =~ /^(safe_paramlist)(\d+)_(\S+)/) {
+ my ($method, $numregexp, $varname) = ($1, $2, $3);
+ return $curproc->$method($numregexp, $varname);
+ }
+ elsif ($comname =~ /^(safe_param)_(\S+)/) {
+ my ($method, $varname) = ($1, $2);
+ return $curproc->$method($varname);
}
else {
croak("unknown method $comname");
diff --git a/fml/lib/FML/Process/CGI/Param.pm b/fml/lib/FML/Process/CGI/Param.pm
index 202e7538..ddddbb1c 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.3 2001/11/11 01:08:00 fukachan Exp $
+# $FML: Param.pm,v 1.4 2001/11/11 11:05:45 fukachan Exp $
#
package FML::Process::CGI::Param;
@@ -41,13 +41,19 @@ It provides basic functions and flow.
@EXPORT_OK = qw(safe_param %allow_regexp);
-my %allow_regexp = (
- 'address' => '[-a-z0-9_]@[-A-Z0-9\.]+',
- 'ml_name' => '[-a-z0-9_]+',
- 'action' => '[-a-z_]+',
- 'user' => '[-a-z0-9_]+',
- 'article_id' => '\d+',
- );
+my %allow_regexp =
+ (
+ 'address' => '[-a-z0-9_]@[-A-Z0-9\.]+',
+ 'ml_name' => '[-a-z0-9_]+',
+ 'action' => '[-a-z_]+',
+ 'user' => '[-a-z0-9_]+',
+ 'article_id' => '\d+',
+ );
+
+my %allow_regexp_list =
+ (
+ 'threadcgi_change_status' => 'change_status\.(__ml_name_regexp__)\/(\d+)',
+ );
# Descriptions:
@@ -76,6 +82,38 @@ sub safe_param
}
+# Descriptions:
+# Arguments: $self $args
+# Side Effects:
+# History: fml 4.0's SecureP()
+# Return Value: none
+sub safe_paramlist
+{
+ my ($self, $numregexp, $key) = @_;
+ my (@list) = ();
+
+ # convert $key => regexp
+ $key = $allow_regexp_list{ $key };
+ for my $regexpkey (keys %allow_regexp) {
+ my $x = "__${regexpkey}_regexp__";
+ my $y = $allow_regexp{$regexpkey};
+ $key =~ s/$x/$y/g;
+ }
+
+ # search
+ for my $x (param()) {
+ if ($x =~ /^$key$/) {
+ my $value = defined param($x) ? param($x) : '';
+ if ($numregexp == 1) { push(@list, [ $1, $value ] );}
+ if ($numregexp == 2) { push(@list, [ $1, $2, $value ] );}
+ if ($numregexp == 3) { push(@list, [ $1, $2, $3, $value ] );}
+ }
+ }
+
+ return \@list;
+}
+
+
=head1 AUTHOR
Ken'ichi Fukamachi