Ticket #143: 0001-Add-configuration-parameter-xtc_header-which-specifi.patch

File 0001-Add-configuration-parameter-xtc_header-which-specifi.patch, 2.5 KB (added by saragus, 14 years ago)

Patch implementing the discussed feature (against SVN of the day)

  • Classifier/Bayes.pm

    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  
    271271
    272272    $self->config_( 'subject_mod_pos',  1 );
    273273
     274    # Sets the string used as a key for the added text classification header
     275
     276    $self->config_( 'xtc_header', 'X-Text-Classification');
     277
    274278    # Get the hostname for use in the X-POPFile-Link header
    275279
    276280    $self->{hostname__} = hostname;
    sub classify_and_modify  
    29252929                    # Strip out the X-Text-Classification header that
    29262930                    # is in an incoming message
    29272931
    2928                     next if ( $line =~ /^X-Text-Classification:/i );
     2932                    my $xtc_header = $self->config_("xtc_header");
     2933                    next if ( $line =~ /^$xtc_header:/i );
    29292934                    next if ( $line =~ /^X-POPFile-Link:/i );
    29302935
    29312936                    # Store any lines that appear as though they may
    sub classify_and_modify  
    30373042    $msg_head_after =~ s/\015\z/$crlf/;
    30383043
    30393044    # Add the XTC header
    3040 
     3045    my $xtc_header = $self->config_("xtc_header");
    30413046    if ( ( $xtc_insertion ) && ( !$quarantine ) ) {
    3042         $msg_head_after .= "X-Text-Classification: $classification$crlf";
     3047        $msg_head_after .= "$xtc_header: $classification$crlf";
    30433048    }
    30443049
    30453050    # Add the XPL header
    sub classify_and_modify  
    30883093           print $client "To: $encoded_to$crlf";
    30893094           print $client "Date: " . $self->{parser__}->get_header( 'date' ) . "$crlf";
    30903095           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 );
    30923097           print $client "X-POPFile-Link: $xpl$crlf" if ( $xpl_insertion );
    30933098           print $client "MIME-Version: 1.0$crlf";
    30943099           print $client "Content-Type: multipart/report; boundary=\"$slot\"$crlf$crlf--$slot$crlf";