From a7adfd6d070a3132fbd93c65034a7d463ebc1055 Mon Sep 17 00:00:00 2001
Date: Mon, 15 Mar 2010 17:16:37 +0100
Subject: [PATCH] Add configuration parameter xtc_header which specifies the name of the
header where to add the classification of the message, default value
is 'X-Text-Classification'.
This is useful for example for implementing a chained popfile
configuration.
---
Classifier/Bayes.pm | 13 +++++++++----
1 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/Classifier/Bayes.pm b/Classifier/Bayes.pm
index 71b7e15..35f3d26 100644
a
|
b
|
sub initialize
|
271 | 271 | |
272 | 272 | $self->config_( 'subject_mod_pos', 1 ); |
273 | 273 | |
| 274 | # Sets the string used as a key for the added text classification header |
| 275 | |
| 276 | $self->config_( 'xtc_header', 'X-Text-Classification'); |
| 277 | |
274 | 278 | # Get the hostname for use in the X-POPFile-Link header |
275 | 279 | |
276 | 280 | $self->{hostname__} = hostname; |
… |
… |
sub classify_and_modify
|
2925 | 2929 | # Strip out the X-Text-Classification header that |
2926 | 2930 | # is in an incoming message |
2927 | 2931 | |
2928 | | next if ( $line =~ /^X-Text-Classification:/i ); |
| 2932 | my $xtc_header = $self->config_("xtc_header"); |
| 2933 | next if ( $line =~ /^$xtc_header:/i ); |
2929 | 2934 | next if ( $line =~ /^X-POPFile-Link:/i ); |
2930 | 2935 | |
2931 | 2936 | # Store any lines that appear as though they may |
… |
… |
sub classify_and_modify
|
3037 | 3042 | $msg_head_after =~ s/\015\z/$crlf/; |
3038 | 3043 | |
3039 | 3044 | # Add the XTC header |
3040 | | |
| 3045 | my $xtc_header = $self->config_("xtc_header"); |
3041 | 3046 | if ( ( $xtc_insertion ) && ( !$quarantine ) ) { |
3042 | | $msg_head_after .= "X-Text-Classification: $classification$crlf"; |
| 3047 | $msg_head_after .= "$xtc_header: $classification$crlf"; |
3043 | 3048 | } |
3044 | 3049 | |
3045 | 3050 | # Add the XPL header |
… |
… |
sub classify_and_modify
|
3088 | 3093 | print $client "To: $encoded_to$crlf"; |
3089 | 3094 | print $client "Date: " . $self->{parser__}->get_header( 'date' ) . "$crlf"; |
3090 | 3095 | print $client "Subject:$msg_subject$crlf" if ( defined( $msg_subject ) ); |
3091 | | print $client "X-Text-Classification: $classification$crlf" if ( $xtc_insertion ); |
| 3096 | print $client "$xtc_header: $classification$crlf" if ( $xtc_insertion ); |
3092 | 3097 | print $client "X-POPFile-Link: $xpl$crlf" if ( $xpl_insertion ); |
3093 | 3098 | print $client "MIME-Version: 1.0$crlf"; |
3094 | 3099 | print $client "Content-Type: multipart/report; boundary=\"$slot\"$crlf$crlf--$slot$crlf"; |