diff options
| author | fukachan <fukachan> | 2001-09-23 11:34:42 +0000 |
|---|---|---|
| committer | fukachan <fukachan> | 2001-09-23 11:34:42 +0000 |
| commit | c8f20a5d6d4e7e8125d3235082e2555f46a188d0 (patch) | |
| tree | f3301c23587ab446cc7b8906828ff04d3f55b4a2 | |
| parent | b651de7da8d77c5e061c84d29976585311a65b34 (diff) | |
| download | fml8-c8f20a5d6d4e7e8125d3235082e2555f46a188d0.tar.gz fml8-c8f20a5d6d4e7e8125d3235082e2555f46a188d0.tar.bz2 fml8-c8f20a5d6d4e7e8125d3235082e2555f46a188d0.zip | |
move clean_up_buffer() and compare_euc_string() to
FML::Filter::BodyCheck and FML::Language::Japanese::Utils
respectively to remove FML::Filter::Utils.
| -rw-r--r-- | fml/lib/FML/Filter/BodyCheck.pm | 24 | ||||
| -rw-r--r-- | fml/lib/FML/Filter/Utils.pm | 124 | ||||
| -rw-r--r-- | fml/lib/FML/Language/Japanese/Utils.pm | 50 |
3 files changed, 72 insertions, 126 deletions
diff --git a/fml/lib/FML/Filter/BodyCheck.pm b/fml/lib/FML/Filter/BodyCheck.pm index 69cdb208..6e70e540 100644 --- a/fml/lib/FML/Filter/BodyCheck.pm +++ b/fml/lib/FML/Filter/BodyCheck.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: BodyCheck.pm,v 1.4 2001/08/19 14:59:07 fukachan Exp $ +# $FML: BodyCheck.pm,v 1.5 2001/09/23 09:30:28 fukachan Exp $ # package FML::Filter::BodyCheck; @@ -324,6 +324,28 @@ sub is_signature } +=head2 C<clean_up_buffer($args)> + +remove some special syntax pattern for further check. +For example, the pattern is a mail address. +We remove it and check the remained buffer whether it is safe or not. + +=cut + +sub clean_up_buffer +{ + my ($self, $xbuf) = @_; + + # 1. cut off Email addresses (exceptional). + $xbuf =~ s/\S+@[-\.0-9A-Za-z]+/account\@domain/g; + + # 2. remove invalid syntax seen in help file with the bug? ;D + $xbuf =~ s/^_CTK_//g; + $xbuf =~ s/\n_CTK_//g; + + $xbuf; +} + =head1 AUTHOR diff --git a/fml/lib/FML/Filter/Utils.pm b/fml/lib/FML/Filter/Utils.pm deleted file mode 100644 index 59ad045b..00000000 --- a/fml/lib/FML/Filter/Utils.pm +++ /dev/null @@ -1,124 +0,0 @@ -#-*- perl -*- -# -# 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. -# -# $FML: Utils.pm,v 1.2 2001/03/30 09:18:44 fukachan Exp $ -# - -package FML::Filter::Utils; -use strict; -use vars qw(@ISA @EXPORT @EXPORT_OK $AUTOLOAD); -use Carp; - -=head1 NAME - -FML::Filter::Utils - what is this - -=head1 SYNOPSIS - -=head1 DESCRIPTION - -=head1 METHODS - -=head2 C<new()> - -usual constructor. - -=cut - - -sub new -{ - my ($self) = @_; - my ($type) = ref($self) || $self; - my $me = {}; - return bless $me, $type; -} - - -=head2 C<clean_up_buffer($args)> - -remove some special syntax pattern for further check. -For example, the pattern is a mail address. -We remove it and check the remained buffer whether it is safe or not. - -=cut - -sub clean_up_buffer -{ - my ($self, $xbuf) = @_; - - # 1. cut off Email addresses (exceptional). - $xbuf =~ s/\S+@[-\.0-9A-Za-z]+/account\@domain/g; - - # 2. remove invalid syntax seen in help file with the bug? ;D - $xbuf =~ s/^_CTK_//g; - $xbuf =~ s/\n_CTK_//g; - - $xbuf; -} - - -# XXX fml 4.0: EUCCompare($buf, $pat) -# XXX where $pat should be $& (matched pattern) -sub euc_compare -{ - my ($self, $a, $pat) = @_; - - # (Refeence: jcode 2.12) - # $re_euc_c = '[\241-\376][\241-\376]'; - # $re_euc_kana = '\216[\241-\337]'; - # $re_euc_0212 = '\217[\241-\376][\241-\376]'; - my ($re_euc_c, $re_euc_kana, $re_euc_0212); - $re_euc_c = '[\241-\376][\241-\376]'; - $re_euc_kana = '\216[\241-\337]'; - $re_euc_0212 = '\217[\241-\376][\241-\376]'; - - # always true if given buffer is not EUC. - if ($a !~ /($re_euc_c|$re_euc_kana|$re_euc_0212)/) { - &Log("EUCCompare: do nothing for non EUC strings");# if $debug; - return 1; - } - - # extract EUC code (e.g. .*EUC_PATTERN.*) - # but how to do for "EUC ASCII EUC" case ??? - my ($pa, $loc, $i); - do { - if ($a =~ /(($re_euc_c|$re_euc_kana|$re_euc_0212)+)/) { - $pa = $1; - $loc = index($pa, $pat); - } - - print "buf = <$a> pa=<$pa> pat=<$pat> loc=$loc\n"; - - return 1 if ($loc % 2) == 0; - - $a = substr($a, index($a, $pa) + length($pa) ); - } while ($i++ < 16); - - 0; -} - - -=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::Filter::Utils appeared in fml5 mailing list driver package. -See C<http://www.fml.org/> for more details. - -=cut - - -1; diff --git a/fml/lib/FML/Language/Japanese/Utils.pm b/fml/lib/FML/Language/Japanese/Utils.pm index b573b555..3b4c0392 100644 --- a/fml/lib/FML/Language/Japanese/Utils.pm +++ b/fml/lib/FML/Language/Japanese/Utils.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: Utils.pm,v 1.1.1.1 2001/07/31 14:13:08 fukachan Exp $ +# $FML: Utils.pm,v 1.2 2001/07/31 14:19:42 fukachan Exp $ # package FML::Language::Japanese::Utils; @@ -79,6 +79,54 @@ sub _look_not_iso2022jp_string } +=head2 C<compare_euc_string($buf, $pat)> + +search $pat in EUC string $buf. +return 1 if found or 0 if not. + +=cut + + +# XXX fml 4.0: EUCCompare($buf, $pat) +# XXX where $pat should be $& (matched pattern) +sub compare_euc_string +{ + my ($self, $a, $pat) = @_; + + # (Refeence: jcode 2.12) + # $re_euc_c = '[\241-\376][\241-\376]'; + # $re_euc_kana = '\216[\241-\337]'; + # $re_euc_0212 = '\217[\241-\376][\241-\376]'; + my ($re_euc_c, $re_euc_kana, $re_euc_0212); + $re_euc_c = '[\241-\376][\241-\376]'; + $re_euc_kana = '\216[\241-\337]'; + $re_euc_0212 = '\217[\241-\376][\241-\376]'; + + # always true if given buffer is not EUC. + if ($a !~ /($re_euc_c|$re_euc_kana|$re_euc_0212)/) { + &Log("EUCCompare: do nothing for non EUC strings");# if $debug; + return 1; + } + + # extract EUC code (e.g. .*EUC_PATTERN.*) + # but how to do for "EUC ASCII EUC" case ??? + my ($pa, $loc, $i); + do { + if ($a =~ /(($re_euc_c|$re_euc_kana|$re_euc_0212)+)/) { + $pa = $1; + $loc = index($pa, $pat); + } + + print STDERR "buf = <$a> pa=<$pa> pat=<$pat> loc=$loc\n" if $ENV{'debug'}; + + return 1 if ($loc % 2) == 0; + + $a = substr($a, index($a, $pa) + length($pa) ); + } while ($i++ < 16); + + 0; +} + =head1 AUTHOR |
