projects
/
spider.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
remove Prot.pm, sort %valid fields
[spider.git]
/
perl
/
Filter.pm
diff --git
a/perl/Filter.pm
b/perl/Filter.pm
index 4443fc5570ac2360d40af67587c5d10f028aeec4..a83a5217ec86678014c42b0cffd7020305944052 100644
(file)
--- a/
perl/Filter.pm
+++ b/
perl/Filter.pm
@@
-10,7
+10,7
@@
#
# Copyright (c) 1999 Dirk Koopman G1TLH
#
#
# Copyright (c) 1999 Dirk Koopman G1TLH
#
-#
$Id$
+#
#
# The NEW INSTRUCTIONS
#
#
# The NEW INSTRUCTIONS
#
@@
-34,12
+34,6
@@
use Prefix;
use strict;
use strict;
-use vars qw($VERSION $BRANCH);
-$VERSION = sprintf( "%d.%03d", q$Revision$ =~ /(\d+)\.(\d+)/ );
-$BRANCH = sprintf( "%d.%03d", q$Revision$ =~ /\d+\.\d+\.(\d+)\.(\d+)/ || (0,0));
-$main::build += $VERSION;
-$main::branch += $BRANCH;
-
use vars qw ($filterbasefn $in);
$filterbasefn = "$main::root/filter";
use vars qw ($filterbasefn $in);
$filterbasefn = "$main::root/filter";
@@
-116,17
+110,26
@@
sub read_in
$in = undef;
my $s = readfilestr($fn);
my $newin = eval $s;
$in = undef;
my $s = readfilestr($fn);
my $newin = eval $s;
- dbg($@) if $@;
+ if ($@) {
+ dbg($@);
+ unlink($fn);
+ return undef;
+ }
if ($in) {
$newin = new('Filter::Old', $sort, $call, $flag);
$newin->{filter} = $in;
if ($in) {
$newin = new('Filter::Old', $sort, $call, $flag);
$newin->{filter} = $in;
- } els
e
{
+ } els
if (ref $newin && $newin->can('getfilkeys'))
{
my $filter;
my $key;
foreach $key ($newin->getfilkeys) {
$newin->compile($key, 'reject');
$newin->compile($key, 'accept');
}
my $filter;
my $key;
foreach $key ($newin->getfilkeys) {
$newin->compile($key, 'reject');
$newin->compile($key, 'accept');
}
+ } else {
+ # error on reading file, delete and exit
+ dbg("empty or unreadable filter: $fn, deleted");
+ unlink($fn);
+ return undef;
}
return $newin;
}
}
return $newin;
}
@@
-307,7
+310,7
@@
sub install
} elsif ($name eq 'USER_DEFAULT') {
@dxchan = DXChannel::get_all_users();
} else {
} elsif ($name eq 'USER_DEFAULT') {
@dxchan = DXChannel::get_all_users();
} else {
- $dxchan = DXChannel
->
get($name);
+ $dxchan = DXChannel
::
get($name);
push @dxchan, $dxchan if $dxchan;
}
foreach $dxchan (@dxchan) {
push @dxchan, $dxchan if $dxchan;
}
foreach $dxchan (@dxchan) {
@@
-370,7
+373,8
@@
sub parse
my $user;
# check the line for non legal characters
my $user;
# check the line for non legal characters
- return ('ill', $dxchan->msg('e19')) if $line =~ /[^\s\w,_\-\*\/\(\)!]/;
+ return ('ill', $dxchan->msg('e19')) if $dxchan->priv < 8 and $line =~ /{.*}/;
+ return ('ill', $dxchan->msg('e19')) if $line !~ /{.*}/ && $line =~ /[^\s\w,_\-\*\/\(\)!]/;
# add some spaces for ease of parsing
$line =~ s/([\(\)])/ $1 /g;
# add some spaces for ease of parsing
$line =~ s/([\(\)])/ $1 /g;
@@
-382,7
+386,7
@@
sub parse
while (@f) {
if ($ntoken == 0) {
while (@f) {
if ($ntoken == 0) {
- if (@f && $dxchan->priv >= 8 && ((is_callsign(uc $f[0]) && DXUser
->
get(uc $f[0])) || $f[0] =~ /(?:node|user)_default/)) {
+ if (@f && $dxchan->priv >= 8 && ((is_callsign(uc $f[0]) && DXUser
::
get(uc $f[0])) || $f[0] =~ /(?:node|user)_default/)) {
$call = shift @f;
if ($f[0] eq 'input') {
shift @f;
$call = shift @f;
if ($f[0] eq 'input') {
shift @f;
@@
-470,18
+474,23
@@
sub parse
}
@val = @nval;
}
}
@val = @nval;
}
- if ($fref->[1] eq 'a') {
+ if ($fref->[1] eq 'a'
|| $fref->[1] eq 't'
) {
my @t;
for (@val) {
my @t;
for (@val) {
- s/\*//g;
- push @t, "\$r->[$fref->[2]]=~/$_/i";
+ s/\*//g; # remove any trailing *
+ if (/^\{.*\}$/) { # we have a regex
+ s/^\{//;
+ s/\}$//;
+ return ('regex', $dxchan->msg('e38', $_)) unless (qr{$_})
+ }
+ push @t, "\$r->[$fref->[2]]=~m{$_}i";
}
$s .= "(" . join(' || ', @t) . ")";
} elsif ($fref->[1] eq 'c') {
my @t;
for (@val) {
s/\*//g;
}
$s .= "(" . join(' || ', @t) . ")";
} elsif ($fref->[1] eq 'c') {
my @t;
for (@val) {
s/\*//g;
- push @t, "\$r->[$fref->[2]]=~
/^\U$_/
";
+ push @t, "\$r->[$fref->[2]]=~
m{^\U$_}
";
}
$s .= "(" . join(' || ', @t) . ")";
} elsif ($fref->[1] eq 'n') {
}
$s .= "(" . join(' || ', @t) . ")";
} elsif ($fref->[1] eq 'n') {
@@
-508,13
+517,6
@@
sub parse
push @t, "(\$r->[$fref->[2]]>=$1 && \$r->[$fref->[2]]<=$2)";
}
$s .= "(" . join(' || ', @t) . ")";
push @t, "(\$r->[$fref->[2]]>=$1 && \$r->[$fref->[2]]<=$2)";
}
$s .= "(" . join(' || ', @t) . ")";
- } elsif ($fref->[1] eq 't') {
- my @t;
- for (@val) {
- s/\*//g;
- push @t, "\$r->[$fref->[2]]=~/$_/i";
- }
- $s .= "(" . join(' || ', @t) . ")";
} else {
confess("invalid letter $fref->[1]");
}
} else {
confess("invalid letter $fref->[1]");
}
@@
-547,7
+549,7
@@
sub cmd
return $dxchan->msg('filter5') unless $line;
my ($r, $filter, $fno, $user, $s) = $self->parse($dxchan, $sort, $line);
return $dxchan->msg('filter5') unless $line;
my ($r, $filter, $fno, $user, $s) = $self->parse($dxchan, $sort, $line);
- my $u = DXUser
->
get_current($user);
+ my $u = DXUser
::
get_current($user);
return (1, $dxchan->msg('isow', $user)) if $u && $u->isolate;
return (1, $filter) if $r;
return (1, $dxchan->msg('isow', $user)) if $u && $u->isolate;
return (1, $filter) if $r;
@@
-594,8
+596,11
@@
use vars qw(@ISA);
# to 'Filter::it'
#
# The fieldsort is the type of field that we are dealing with which
# to 'Filter::it'
#
# The fieldsort is the type of field that we are dealing with which
-# currently can be 'a', 'n', 'r' or 'd'. 'a' is alphanumeric, 'n' is
-# numeric, 'r' is ranges of pairs of numeric values and 'd' is default.
+# currently can be 'a', 'n', 'r' or 'd'.
+# 'a' is alphanumeric
+# 'n' is# numeric
+# 'r' is ranges of pairs of numeric values
+# 'd' is default (effectively, don't filter)
#
# Filter::it basically goes thru the list of comparisons from top to
# bottom and when one matches it will return the action and the action data as a list.
#
# Filter::it basically goes thru the list of comparisons from top to
# bottom and when one matches it will return the action and the action data as a list.
@@
-634,9
+639,9
@@
sub it
return ($action, $actiondata) if $val >= $range[$i] && $val <= $range[$i+1];
}
} elsif ($fieldsort eq 'a') {
return ($action, $actiondata) if $val >= $range[$i] && $val <= $range[$i+1];
}
} elsif ($fieldsort eq 'a') {
- return ($action, $actiondata) if $_[$field] =~ m{$comp};
+ return ($action, $actiondata) if $_[$field] =~ m{$comp}
i
;
} else {
} else {
- return ($action, $actiondata); # the default action
+ return ($action, $actiondata); # the default action
(just pass through)
}
}
}
}
}
}