summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--fml/lib/FML/Restriction/Base.pm92
-rw-r--r--fml/lib/FML/Restriction/CGI.pm103
2 files changed, 195 insertions, 0 deletions
diff --git a/fml/lib/FML/Restriction/Base.pm b/fml/lib/FML/Restriction/Base.pm
new file mode 100644
index 00000000..d5da7fb9
--- /dev/null
+++ b/fml/lib/FML/Restriction/Base.pm
@@ -0,0 +1,92 @@
+#!/usr/local/bin/perl -w
+#-*- perl -*-
+#
+# Copyright (C) 2001 Ken'ichi Fukamachi
+# All rights reserved.
+#
+# $FML: SafeBase.pm,v 1.1 2001/11/25 09:12:58 fukachan Exp $
+#
+
+package FML::Restriction::Base;
+
+use vars qw($debug @ISA @EXPORT @EXPORT_OK);
+use strict;
+use Carp;
+
+=head1 NAME
+
+FML::Restriction::Base -- define safe data class
+
+=head1 SYNOPSIS
+
+ use FML::Restriction::Base;
+ $safe = new FML::Restriction::Base;
+ my $regexp = $safe->regexp();
+
+=head1 DESCRIPTION
+
+FML::Restriction::Base provides data type considered as safe.
+
+=head1 METHODS
+
+=head2 C<new($args)>
+
+usual constructor.
+
+=cut
+
+
+# avoid default fml new() since we do not need it.
+sub new
+{
+ my ($self) = @_;
+ my ($type) = ref($self) || $self;
+ my $me = {};
+ return bless $me, $type;
+}
+
+
+=head1 Basic Parameter Definition for common use
+
+ %basic_variable
+
+=cut
+
+
+my %basic_variable =
+ (
+ '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+',
+ );
+
+
+sub basic_variable
+{
+ return \%basic_variable;
+}
+
+
+=head1 AUTHOR
+
+Ken'ichi Fukamachi
+
+=head1 COPYRIGHT
+
+Copyright (C) 2001 Ken'ichi Fukamachi
+
+All rights reserved. This program is free software; you can
+redistribute it and/or modify it under the same terms as Perl itself.
+
+=head1 HISTORY
+
+FML::Process::Configure appeared in fml5 mailing list driver package.
+See C<http://www.fml.org/> for more details.
+
+=cut
+
+
+1;
diff --git a/fml/lib/FML/Restriction/CGI.pm b/fml/lib/FML/Restriction/CGI.pm
new file mode 100644
index 00000000..859bdcd3
--- /dev/null
+++ b/fml/lib/FML/Restriction/CGI.pm
@@ -0,0 +1,103 @@
+#!/usr/local/bin/perl -w
+#-*- perl -*-
+#
+# Copyright (C) 2001 Ken'ichi Fukamachi
+# All rights reserved.
+#
+# $FML: SafeCGI.pm,v 1.1 2001/11/25 09:12:58 fukachan Exp $
+#
+
+package FML::Restriction::CGI;
+
+use vars qw($debug @ISA @EXPORT @EXPORT_OK);
+use strict;
+use Carp;
+
+use FML::Restriction::Base;
+@ISA = qw(FML::Restriction::Base);
+
+=head1 NAME
+
+FML::Restriction::CGI -- define safe data class
+
+=head1 SYNOPSIS
+
+ use FML::Restriction::CGI;
+ $safe = new FML::Restriction::CGI;
+ my $regexp = $safe->regexp();
+
+=head1 DESCRIPTION
+
+FML::Restriction::CGI provides data type considered as safe.
+
+=head1 METHODS
+
+=head1 Safe Parameter Definition for CGI use
+
+Please extract regexp hash { varname => allowed_regexp } as HASH
+REFERENCE via the following access method:
+
+ param_regexp()
+ method_regexp()
+
+=cut
+
+
+my %cgi_methond =
+ (
+ 'threadcgi_change_status' => 'change_status\.(__ml_name_regexp__)\/(\d+)',
+ );
+
+
+
+sub param_regexp
+{
+ my ($self) = @_;
+ return $self->basic_variable();
+}
+
+
+sub method_regexp
+{
+ my ($self) = @_;
+ my $basic_variable = $self->basic_variable();
+
+ # expand __var__regexp__ to regular expression defined in other hash
+ for my $key (keys %cgi_methond) {
+ my $value = $cgi_methond{ $key };
+ if ($value =~ /__/o) {
+
+ # expand variables defined in %basic_variable HASH
+ for my $regexpkey (keys %$basic_variable) {
+ my $x = "__${regexpkey}_regexp__";
+ my $y = $basic_variable->{$regexpkey};
+ $value =~ s/$x/$y/g;
+ $cgi_methond{ $key } = $value;
+ }
+ }
+ }
+
+ return \%cgi_methond;
+}
+
+
+=head1 AUTHOR
+
+Ken'ichi Fukamachi
+
+=head1 COPYRIGHT
+
+Copyright (C) 2001 Ken'ichi Fukamachi
+
+All rights reserved. This program is free software; you can
+redistribute it and/or modify it under the same terms as Perl itself.
+
+=head1 HISTORY
+
+FML::Process::Configure appeared in fml5 mailing list driver package.
+See C<http://www.fml.org/> for more details.
+
+=cut
+
+
+1;