diff options
| author | fukachan <fukachan> | 2004-03-04 04:30:12 +0000 |
|---|---|---|
| committer | fukachan <fukachan> | 2004-03-04 04:30:12 +0000 |
| commit | 55e26f45fb57cb2a6e056af758a24c94ea15bf4a (patch) | |
| tree | dd022eb101ab7b3ad425e983c0668e34d5df02d4 /fml/lib/FML/Restriction | |
| parent | b74f9240b7cd9c74998b366db4227bb4f83d86cb (diff) | |
| download | fml8-55e26f45fb57cb2a6e056af758a24c94ea15bf4a.tar.gz fml8-55e26f45fb57cb2a6e056af758a24c94ea15bf4a.tar.bz2 fml8-55e26f45fb57cb2a6e056af758a24c94ea15bf4a.zip | |
merge new command mail framework [from command-reconstruct branch]
Diffstat (limited to 'fml/lib/FML/Restriction')
| -rw-r--r-- | fml/lib/FML/Restriction/Command.pm | 69 |
1 files changed, 58 insertions, 11 deletions
diff --git a/fml/lib/FML/Restriction/Command.pm b/fml/lib/FML/Restriction/Command.pm index 86ff7200..2d73d9f3 100644 --- a/fml/lib/FML/Restriction/Command.pm +++ b/fml/lib/FML/Restriction/Command.pm @@ -1,10 +1,10 @@ #-*- perl -*- # -# Copyright (C) 2002,2003 Ken'ichi Fukamachi +# Copyright (C) 2002,2003,2004 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. # -# $FML: Command.pm,v 1.8 2002/12/15 15:17:18 fukachan Exp $ +# $FML: Command.pm,v 1.9.4.1 2004/03/04 04:07:54 fukachan Exp $ # package FML::Restriction::Command; @@ -24,22 +24,30 @@ collection of utility functions used in command routines. =head1 METHODS -=head2 is_secure_command_string($str) +=cut -check if $str string looks secure ? -return 1 if secure. -=cut +# Descriptions: constructor. +# Arguments: OBJ($self) OBJ($curproc) +# Side Effects: none +# Return Value: OBJ +sub new +{ + my ($self, $curproc) = @_; + my ($type) = ref($self) || $self; + my $me = { _curproc => $curproc }; + return bless $me, $type; +} -# Descriptions: $s looks secure ? -# Arguments: STR($s) +# Descriptions: $s looks secure as a command ? +# Arguments: OBJ($self) STR($s) # Side Effects: none # History: fml 4.0's SecureP() # Return Value: NUM(1 or 0) -sub is_secure_command_string +sub _is_secure_command_string { - my ($s) = @_; + my ($self, $s) = @_; # 0. clean up $s =~ s/^\s*\#\s*//o; # remove ^# @@ -69,6 +77,45 @@ sub is_secure_command_string } +# Descriptions: incremental regexp match for the given data. +# Arguments: OBJ($self) VAR_ARGS($data) +# Side Effects: none +# Return Value: NUM(>0 or 0) +sub command_regexp_match +{ + my ($self, $data) = @_; + my $r = 0; + + use FML::Restriction::Base; + my $safe = new FML::Restriction::Base; + + if (ref($data)) { + if (ref($data) eq 'ARRAY') { + DATA: + for my $x (@$data) { + next DATA unless $x; + + unless ($safe->regexp_match('command', $x)) { + $r = 0; + last DATA; + } + else { + $r++; + } + } + } + else { + croak("FML::Restriction::Command: wrong data"); + } + } + else { + $r = $safe->regexp_match('command', $data); + } + + return $r; +} + + =head1 CODING STYLE See C<http://www.fml.org/software/FNF/> on fml coding style guide. @@ -79,7 +126,7 @@ Ken'ichi Fukamachi =head1 COPYRIGHT -Copyright (C) 2002,2003 Ken'ichi Fukamachi +Copyright (C) 2002,2003,2004 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. |
