my $valid = 0;
return (1, $self->msg('e5')) if $self->remotecmd;
+my @bad;
+if (@bad = BadWords::check($line)) {
+ $self->badcount(($self->badcount||0) + @bad);
+ return (1, $self->msg('e17', @bad));
+}
+
# do we have at least two args?
return (1, $self->msg('dx2')) unless @f >= 2;
return (1, @out) unless $valid;
-my @bad;
-if (@bad = BadWords::check($line)) {
- $self->badcount(($self->badcount||0) + @bad);
- return (1, $self->msg('e17', @bad));
-}
# Store it here (but only if it isn't baddx)
if ($DXProt::baddx->in($spotted)) {
use IO::File;
-use vars qw($badword @regex);
+use vars qw($badword $regexcode);
my $oldfn = "$main::data/badwords";
my $regex = "$main::data/badw_regex";
sub create_regex
{
my @out;
- @regex = ();
-
my $fh = new IO::File $regex;
if ($fh) {
+ my $s = "sub { my \$str = shift; my \@out; \n";
while (<$fh>) {
chomp;
next if /^\s*\#/;
# and repeated characters in it
my $w = uc $_;
my @l = split //, $w;
- my $e = join '+[\s\W]+', @l;
- my $s = eval qq{sub { return \$_[0] =~ /$e+/ ? '$w' : () } };
- push @regex, $s unless $@;
- dbg("create_regex: $@") if $@;
+ my $e = join '+[\s\W]*', @l;
+ $s .= "push \@out, \$1 if \$str =~ /($e)/;\n";
}
}
+ $s .= "return \@out;\n}";
+ $regexcode = eval $s;
+ dbg($s) if isdbg('badword');
+ if ($@) {
+ @out = ($@);
+ dbg($@);
+ return @out;
+ }
$fh->close;
} else {
my $l = "can't open $regex $!";
{
my $s = uc shift;
my @out;
-
- for (@regex) {
- push @out, &$_($s);
- }
+
+ dbg($s) if isdbg('badword');
+ push @out, &$regexcode($s) if $regexcode;
return @out if @out;