~ubuntu-branches/ubuntu/utopic/spamassassin/utopic-updates

« back to all changes in this revision

Viewing changes to lib/Mail/SpamAssassin/Plugin/HeaderEval.pm

  • Committer: Package Import Robot
  • Author(s): Noah Meyerhans
  • Date: 2014-02-14 22:45:15 UTC
  • mfrom: (0.8.1) (0.6.2) (5.1.22 sid)
  • Revision ID: package-import@ubuntu.com-20140214224515-z1es2twos8xh7n2y
Tags: 3.4.0-1
* New upstream version! (Closes: 738963, 738872, 738867)
* Scrub the environment when switching to the debian-spamd user in
  postinst and cron.daily. (Closes: 738951)
* Enhancements to postinst to better manage ownership of
  /var/lib/spamassassin, via Iain Lane <iain.lane@canonical.com>
  (Closes: 738974)

Show diffs side-by-side

added added

removed removed

Lines of Context:
68
68
  $self->register_eval_rule("check_ratware_envelope_from");
69
69
  $self->register_eval_rule("gated_through_received_hdr_remover");
70
70
  $self->register_eval_rule("received_within_months");
 
71
  $self->register_eval_rule("check_equal_from_domains");
71
72
 
72
73
  return $self;
73
74
}
79
80
  $self->word_is_in_dictionary("aba");
80
81
}
81
82
 
82
 
# sad but true. sort it out, sysadmins!
83
 
my $CCTLDS_WITH_LOTS_OF_OPEN_RELAYS = qr{(?:kr|cn|cl|ar|hk|il|th|tw|sg|za|tr|ma|ua|in|pe|br)};
84
 
my $ROUND_THE_WORLD_RELAYERS = qr{(?:net|com|ca)};
85
 
 
86
83
sub check_for_fake_aol_relay_in_rcvd {
87
84
  my ($self, $pms) = @_;
88
85
  local ($_);
142
139
  my ($self, $pms) = @_;
143
140
  local ($_);
144
141
  $_ = lc $pms->get('Subject');
145
 
  study;
 
142
  study;  # study is a no-op since perl 5.16.0, eliminating related bugs
146
143
 
147
144
  my $id = 0;
148
145
  if (/[-_\.\s]{7,}([-a-z0-9]{4,})$/
769
766
    unshift @received, (shift @local);
770
767
  }
771
768
 
772
 
  my $rcvd;
773
 
 
774
769
  if (scalar(@local)) {
775
770
    my (@fetchmail_times);
776
 
    foreach $rcvd (@local) {
 
771
    foreach my $rcvd (@local) {
777
772
      if ($rcvd =~ m/(\s.?\d+ \S\S\S \d+ \d+:\d+:\d+ \S+)/) {
778
773
        my $date = $1;
779
774
        dbg2("eval: trying Received fetchmail header date for real time: $date");
793
788
  }
794
789
 
795
790
  my (@header_times);
796
 
  foreach $rcvd (@received) {
 
791
  foreach my $rcvd (@received) {
797
792
    if ($rcvd =~ m/(\s.?\d+ \S\S\S \d+ \d+:\d+:\d+ \S+)/) {
798
793
      my $date = $1;
799
794
      dbg2("eval: trying Received header date for real time: $date");
898
893
 
899
894
   $subject =~ s/^\s+//;
900
895
   $subject =~ s/\s+$//;
 
896
   $subject =~ s/^(?:(?:Re|Fwd|Fw|Aw|Antwort|Sv):\s*)+//i;  # Bug 6805
901
897
   return 0 if $subject !~ /\s/;        # don't match one word subjects
902
898
   return 0 if (length $subject < 10);  # don't match short subjects
903
899
   $subject =~ s/[^a-zA-Z]//g;          # only look at letters
976
972
 
977
973
  # Lyris eats message-ids.  also some ezmlm, I think :(
978
974
  $_ = $pms->get("List-Unsubscribe");
979
 
  return 1 if (/<mailto:(?:leave-\S+|\S+-unsubscribe)\@\S+>$/);
 
975
  return 1 if (/<mailto:(?:leave-\S+|\S+-unsubscribe)\@\S+>$/i);
980
976
 
981
977
  # ezmlm again
982
978
  if($self->gated_through_received_hdr_remover($pms)) { return 1; }
1050
1046
  return 0;
1051
1047
}
1052
1048
 
 
1049
# ADDED FROM BUG 6487
 
1050
sub check_equal_from_domains {
 
1051
  my ($self, $pms) = @_;
 
1052
 
 
1053
  my $from = $pms->get('From:addr');
 
1054
  my $envfrom = $pms->get('EnvelopeFrom:addr');
 
1055
 
 
1056
  local $1;
 
1057
  my $fromdomain = '';
 
1058
  #Revised regexp from 6487 comment 3
 
1059
  $fromdomain = $1  if $from =~ /\@([^@]*)\z/;
 
1060
  $fromdomain =~ s/^.+\.([^\.]+\.[^\.]+)$/$1/;
 
1061
  return 0 if $fromdomain eq '';
 
1062
 
 
1063
  my $envfromdomain = '';
 
1064
  $envfromdomain = $1  if $envfrom =~ /\@([^@]*)\z/;
 
1065
  $envfromdomain =~ s/^.+\.([^\.]+\.[^\.]+)$/$1/;
 
1066
  return 0 if $envfromdomain eq '';
 
1067
 
 
1068
  dbg("eval: From 2nd level domain: $fromdomain, EnvelopeFrom 2nd level domain: $envfromdomain");
 
1069
  
 
1070
  return 1 if lc($fromdomain) ne lc($envfromdomain);
 
1071
 
 
1072
  return 0;
 
1073
}
 
1074
 
 
1075
 
1053
1076
###########################################################################
1054
1077
 
1055
1078
# support eval-test verbose debugs using "-Deval"