~ubuntu-branches/ubuntu/lucid/spamassassin/lucid-proposed

« back to all changes in this revision

Viewing changes to lib/Mail/SpamAssassin/PerMsgStatus.pm

  • Committer: Bazaar Package Importer
  • Author(s): Laurent Bigonville, Ubuntu Merge-o-Matic, Laurent Bigonville
  • Date: 2006-07-31 15:40:08 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20060731154008-j37ulp5pgfkddegw
Tags: 3.1.3-1ubuntu1
[ Ubuntu Merge-o-Matic ]
* Merge from debian unstable.

[ Laurent Bigonville ]
* fix debian/control.
* drop debian/patches/40_fix_dns_issue.

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
  my $mail = $spamtest->parse();
28
28
 
29
29
  my $status = $spamtest->check ($mail);
 
30
 
 
31
  my $rewritten_mail;
30
32
  if ($status->is_spam()) {
31
 
    $status->rewrite_mail ();
 
33
    $rewritten_mail = $status->rewrite_mail ();
32
34
  }
33
35
  ...
34
36
 
682
684
sub rewrite_mail {
683
685
  my ($self) = @_;
684
686
 
685
 
  my $mbox = $self->{msg}->get_mbox_separator() || '';
 
687
  my $msg = $self->{msg}->get_mbox_separator() || '';
 
688
 
686
689
  if ($self->{is_spam} && $self->{conf}->{report_safe}) {
687
 
    return $mbox.$self->rewrite_report_safe();
 
690
    $msg .= $self->rewrite_report_safe();
688
691
  }
689
692
  else {
690
 
    return $mbox.$self->rewrite_no_report_safe();
691
 
  }
 
693
    $msg .= $self->rewrite_no_report_safe();
 
694
  }
 
695
 
 
696
  # Make the line endings appropriate for the situation
 
697
  if ($self->{msg}->{line_ending} ne "\n") {
 
698
    $msg =~ s/\r?\n/$self->{msg}->{line_ending}/g;
 
699
  }
 
700
 
 
701
  return $msg;
692
702
}
693
703
 
694
704
# rewrite the message in report_safe mode
998
1008
  my $self = shift;
999
1009
  my $text = shift;
1000
1010
 
1001
 
  $text =~ s/_(\w+?)(?:\((.*?)\))?_/${\($self->_get_tag($1,$2))}/g;
 
1011
  # default to leaving the original string in place, if we cannot find
 
1012
  # a tag for it (bug 4793)
 
1013
  $text =~ s{(_(\w+?)(?:\((.*?)\))?_)}{
 
1014
        my $full = $1;
 
1015
        my $tag = $2;
 
1016
        my $result = $self->_get_tag($tag,$3);
 
1017
        (defined $result) ? $result : $full;
 
1018
      }ge;
 
1019
 
1002
1020
  return $text;
1003
1021
}
1004
1022
 
1091
1109
C<Mail::SpamAssassin::Conf>'s C<TEMPLATE TAGS> section for more details on
1092
1110
tags.
1093
1111
 
 
1112
C<undef> will be returned if a tag by that name has not been defined.
 
1113
 
1094
1114
=cut
1095
1115
 
1096
1116
sub get_tag {
1236
1256
 
1237
1257
          );
1238
1258
 
 
1259
  my $data;
1239
1260
  if (exists $tags{$tag}) {
1240
 
    return $tags{$tag}->(@_);
 
1261
    $data = $tags{$tag}->(@_);
1241
1262
  }
1242
 
  elsif ($self->{tag_data}->{$tag}) {
1243
 
    my $data = $self->{tag_data}->{$tag};
 
1263
  elsif (exists($self->{tag_data}->{$tag})) {
 
1264
    $data = $self->{tag_data}->{$tag};
1244
1265
    if (ref $data eq 'CODE') {
1245
 
      return $data->(@_);
1246
 
    } else {
1247
 
      return $data;
 
1266
      $data = $data->(@_);
1248
1267
    }
1249
1268
  }
1250
1269
  else {
1251
 
    return "";
 
1270
    return;
1252
1271
  }
 
1272
  $data = "" unless defined $data;
 
1273
  return $data;
1253
1274
}
1254
1275
 
1255
1276
###########################################################################
1330
1351
  foreach my $item (qw(
1331
1352
        relays_trusted relays_trusted_str num_relays_trusted
1332
1353
        relays_untrusted relays_untrusted_str num_relays_untrusted
 
1354
        relays_internal relays_internal_str num_relays_internal
 
1355
        relays_external relays_external_str num_relays_external
1333
1356
        num_relays_unparseable
1334
1357
        ))
1335
1358
  {
1338
1361
 
1339
1362
  $self->{tag_data}->{RELAYSTRUSTED} = $self->{relays_trusted_str};
1340
1363
  $self->{tag_data}->{RELAYSUNTRUSTED} = $self->{relays_untrusted_str};
 
1364
  $self->{tag_data}->{RELAYSINTERNAL} = $self->{relays_internal_str};
 
1365
  $self->{tag_data}->{RELAYSEXTERNAL} = $self->{relays_external_str};
1341
1366
  $self->{tag_data}->{LANGUAGES} = $self->{msg}->get_metadata("X-Languages");
1342
1367
 
1343
1368
  # This should happen before we get called, but just in case.
1474
1499
  elsif ($request eq 'X-Spam-Relays-Trusted') {
1475
1500
    $result = $self->{relays_trusted_str};
1476
1501
  }
 
1502
  # external relays list, as string
 
1503
  elsif ($request eq 'X-Spam-Relays-External') {
 
1504
    $result = $self->{relays_external_str};
 
1505
  }
 
1506
  # internal relays list, as string
 
1507
  elsif ($request eq 'X-Spam-Relays-Internal') {
 
1508
    $result = $self->{relays_internal_str};
 
1509
  }
1477
1510
  # ToCc: the combined recipients list
1478
1511
  elsif ($request eq 'ToCc') {
1479
1512
    $result = join("\n", $self->{msg}->get_header('To', $getraw));