summaryrefslogtreecommitdiff
path: root/fml/lib/FML/Restriction/CGI.pm
blob: 9db44e5539be487dca014a03a04ce025aabc3ccb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#-*- perl -*-
#
# Copyright (C) 2001 Ken'ichi Fukamachi
#          All rights reserved.
#
# $FML: CGI.pm,v 1.3 2001/12/22 09:21:11 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 for CGI module

=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+)',
     );



# Descriptions: return basic variable safe expression
#    Arguments: OBJ($self)
# Side Effects: none
# Return Value: HASH_REF
sub param_regexp
{
    my ($self) = @_;
    return $self->basic_variable();
}


# Descriptions: return metho safe expression
#    Arguments: OBJ($self)
# Side Effects: none
# Return Value: HASH_REF
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;