|
From: <jgr...@us...> - 2003-07-27 20:00:33
|
Update of /cvsroot/popfile/engine/Classifier
In directory sc8-pr-cvs1:/tmp/cvs-serv2089/Classifier
Modified Files:
Bayes.pm
Log Message:
Tests for echo_to_dot_
Index: Bayes.pm
===================================================================
RCS file: /cvsroot/popfile/engine/Classifier/Bayes.pm,v
retrieving revision 1.175
retrieving revision 1.176
diff -C2 -d -r1.175 -r1.176
*** Bayes.pm 27 Jul 2003 19:07:20 -0000 1.175
--- Bayes.pm 27 Jul 2003 20:00:30 -0000 1.176
***************
*** 1135,1141 ****
if ( $self->global_config_( 'subject' ) ) {
# Don't add the classification unless it is not present
! if ( !( $msg_subject =~ /\Q$modification\E/ ) &&
( $self->{parameters__}{$classification}{subject} == 1 ) &&
! ( $self->{parameters__}{$classification}{quarantine} == 0 ) ) {
$msg_subject = " $modification$msg_subject";
}
--- 1135,1141 ----
if ( $self->global_config_( 'subject' ) ) {
# Don't add the classification unless it is not present
! if ( !( $msg_subject =~ /\Q$modification\E/ ) && # PROFILE BLOCK START
( $self->{parameters__}{$classification}{subject} == 1 ) &&
! ( $self->{parameters__}{$classification}{quarantine} == 0 ) ) { # PROFILE BLOCK STOP
$msg_subject = " $modification$msg_subject";
}
***************
*** 1147,1152 ****
# Add the XTC header
! $msg_head_after .= "X-Text-Classification: $classification$eol" if ( ( $self->global_config_( 'xtc' ) ) &&
! ( $self->{parameters__}{$classification}{quarantine} == 0 ) );
# Add the XPL header
--- 1147,1152 ----
# Add the XTC header
! $msg_head_after .= "X-Text-Classification: $classification$eol" if ( ( $self->global_config_( 'xtc' ) ) && # PROFILE BLOCK START
! ( $self->{parameters__}{$classification}{quarantine} == 0 ) ); # PROFILE BLOCK STOP
# Add the XPL header
***************
*** 1692,1701 ****
#
# $mail The stream (created with IO::) to send the message to (the remote mail server)
! # $client The local mail client (created with IO::) that needs the response
! # $file a file to print the response to
! # $before Optional string to send to client before the dot is sent
#
# echo all information from the $mail server until a single line with a . is seen
! # Also echoes the line with . to $client but not to $file
#
# ---------------------------------------------------------------------------------------------
--- 1692,1702 ----
#
# $mail The stream (created with IO::) to send the message to (the remote mail server)
! # $client (optional) The local mail client (created with IO::) that needs the response
! # $file (optional) A file to print the response to
! # $before (optional) String to send to client before the dot is sent
#
# echo all information from the $mail server until a single line with a . is seen
! #
! # NOTE Also echoes the line with . to $client but not to $file
#
# ---------------------------------------------------------------------------------------------
***************
*** 1704,1795 ****
my ( $self, $mail, $client, $file, $before ) = @_;
! # These if statements are repetitive to keep the inner loops efficient
!
! if ( defined($file) && defined($client) ) {
! # echo to file and stream
!
! open FILE, $file;
! while ( <$mail> ) {
! # Check for an abort
! last if ( $self->{alive_} == 0 );
!
! # The termination has to be a single line with exactly a dot on it and nothing
! # else other than line termination characters. This is vital so that we do
! # not mistake a line beginning with . as the end of the block
!
! if ( /^\.(\r\n|\r|\n)$/ ) {
! if ( $before ne '' ) {
! print $client $before;
! print FILE $before;
! }
!
! print $client $_;
!
! last;
! }
!
! print $client $_;
! print FILE $_;
!
! }
! close FILE;
! } elsif (defined($client)) {
! # Echo only to stream
! while ( <$mail> ) {
! # Check for an abort
! last if ( $self->{alive_} == 0 );
! # The termination has to be a single line with exactly a dot on it and nothing
! # else other than line termination characters. This is vital so that we do
! # not mistake a line beginning with . as the end of the block
! if ( /^\.(\r\n|\r|\n)$/ ) {
! if ( $before ne '' ) {
! print $client $before;
! }
! print $client $_;
! last;
}
! print $client $_;
! }
! } elsif (defined($file)) {
! # Echo only to file
!
! open FILE, $file;
! while ( <$mail> ) {
! # Check for an abort
! last if ( $self->{alive_} == 0 );
!
! # The termination has to be a single line with exactly a dot on it and nothing
! # else other than line termination characters. This is vital so that we do
! # not mistake a line beginning with . as the end of the block
!
! if ( /^\.(\r\n|\r|\n)$/ ) {
! if ( $before ne '' ) {
! print FILE $before;
! }
! last;
! }
! print FILE $_;
}
- close FILE;
- } else {
- # consume without echoing
! while ( <$mail> ) {
! # Check for an abort
! last if ( $self->{alive_} == 0 );
- # The termination has to be a single line with exactly a dot on it and nothing
- # else other than line termination characters. This is vital so that we do
- # not mistake a line beginning with . as the end of the block
- last if ( /^\.(\r\n|\r|\n)$/ );
- }
}
}
--- 1705,1740 ----
my ( $self, $mail, $client, $file, $before ) = @_;
! open FILE, ">>$file" if ( defined( $file ) );
! while ( <$mail> ) {
! # Check for an abort
! last if ( $self->{alive_} == 0 );
! # The termination has to be a single line with exactly a dot on it and nothing
! # else other than line termination characters. This is vital so that we do
! # not mistake a line beginning with . as the end of the block
! if ( /^\.(\r\n|\r|\n)$/ ) {
! if ( defined( $before ) && ( $before ne '' ) ) {
! print $client $before if ( defined( $client ) );
! print FILE $before if ( defined( $file ) );
}
! # Note that there is no print FILE here. This is correct because we
! # to no want the network terminator . to appear in the file version
! # of any message
! print $client $_ if ( defined( $client ) );
! last;
}
! print $client $_ if ( defined( $client ) );
! print FILE $_ if ( defined( $file ) );
}
+
+ close FILE if ( defined( $file ) );
}
|