summaryrefslogtreecommitdiffstats
path: root/perl/lib/Mail
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rambler-co.ru>2010-06-24 21:24:52 +0400
committerVsevolod Stakhov <vsevolod@rambler-co.ru>2010-06-24 21:24:52 +0400
commit2581146ee7c9433c80e2c4ab5370b7fde966e4f1 (patch)
tree5c0805c9323709047780cd7e734667d41b6ca794 /perl/lib/Mail
parent62108fe767966d44e43f4b23094f220dd0d6bf27 (diff)
downloadrspamd-2581146ee7c9433c80e2c4ab5370b7fde966e4f1.tar.gz
rspamd-2581146ee7c9433c80e2c4ab5370b7fde966e4f1.zip
* Fix URLS command
Diffstat (limited to 'perl/lib/Mail')
-rw-r--r--perl/lib/Mail/Rspamd/Client.pm75
1 files changed, 46 insertions, 29 deletions
diff --git a/perl/lib/Mail/Rspamd/Client.pm b/perl/lib/Mail/Rspamd/Client.pm
index 5c6182868..ad2ab7a86 100644
--- a/perl/lib/Mail/Rspamd/Client.pm
+++ b/perl/lib/Mail/Rspamd/Client.pm
@@ -932,36 +932,53 @@ sub _do_rspamc_command {
my $cur_metric;
my @lines = split (/^/, $in);
- foreach my $line (@lines) {
- if ($line =~ m!Metric: (\S+); (\S+); (\S+) / (\S+)!) {
- $metrics{$1} = {
- isspam => $2,
- score => $3 + 0,
- threshold => $4 + 0,
- symbols => [],
- urls => [],
- messages => [],
- };
- $cur_metric = $1;
- }
- elsif ($line =~ /^Symbol: (\S+);\s*(.+)${EOL}$/ && $cur_metric) {
- # Line with parameters
- my $symref = $metrics{$cur_metric}->{'symbols'};
- push(@$symref, "$1($2)");
- }
- elsif ($line =~ /^Symbol: (\S+)/ && $cur_metric) {
- my $symref = $metrics{$cur_metric}->{'symbols'};
- push(@$symref, $1);
- }
- elsif ($line =~ /^Urls: (.+)$/ && $cur_metric) {
- @{ $metrics{$cur_metric}->{'urls'} } = split /,\s+/, $1;
- }
- elsif ($line =~ /^Message: (.+)/ && $cur_metric) {
- my $symref = $metrics{$cur_metric}->{'messages'};
- push(@$symref, $1);
+ if (lc $self->{'command'} eq 'urls') {
+ $metrics{'default'} = {
+ isspam => 'false',
+ score => 0,
+ threshold => 0,
+ symbols => [],
+ urls => [],
+ messages => [],
+ };
+ foreach my $line (@lines) {
+ if ($line =~ /^Urls: (.+)$/) {
+ @{ $metrics{'default'}->{'urls'} } = split /,\s+/, $1;
+ }
}
- elsif ($line =~ /^${EOL}$/) {
- last;
+ }
+ else {
+ foreach my $line (@lines) {
+ if ($line =~ m!Metric: (\S+); (\S+); (\S+) / (\S+)!) {
+ $metrics{$1} = {
+ isspam => $2,
+ score => $3 + 0,
+ threshold => $4 + 0,
+ symbols => [],
+ urls => [],
+ messages => [],
+ };
+ $cur_metric = $1;
+ }
+ elsif ($line =~ /^Symbol: (\S+);\s*(.+)${EOL}$/ && $cur_metric) {
+ # Line with parameters
+ my $symref = $metrics{$cur_metric}->{'symbols'};
+ push(@$symref, "$1($2)");
+ }
+ elsif ($line =~ /^Symbol: (\S+)/ && $cur_metric) {
+ my $symref = $metrics{$cur_metric}->{'symbols'};
+ push(@$symref, $1);
+ }
+ elsif ($line =~ /^Urls: (.+)$/ && $cur_metric) {
+ @{ $metrics{$cur_metric}->{'urls'} } = split /,\s+/, $1;
+ }
+ elsif ($line =~ /^Message: (.+)/ && $cur_metric) {
+ my $symref = $metrics{$cur_metric}->{'messages'};
+ push(@$symref, $1);
+ }
+ elsif ($line =~ /^${EOL}$/) {
+ last;
+ }
}
}