You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spamassassin.apache.org by fe...@apache.org on 2005/10/24 03:04:32 UTC

svn commit: r327897 - in /spamassassin/trunk/lib/Mail/SpamAssassin: Message.pm PerMsgStatus.pm

Author: felicity
Date: Sun Oct 23 18:04:30 2005
New Revision: 327897

URL: http://svn.apache.org/viewcvs?rev=327897&view=rev
Log:
bug 4363: if a message uses CRLF for line endings, we should use it as well, otherwise stay with LF as usual

Modified:
    spamassassin/trunk/lib/Mail/SpamAssassin/Message.pm
    spamassassin/trunk/lib/Mail/SpamAssassin/PerMsgStatus.pm

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Message.pm
URL: http://svn.apache.org/viewcvs/spamassassin/trunk/lib/Mail/SpamAssassin/Message.pm?rev=327897&r1=327896&r2=327897&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Message.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Message.pm Sun Oct 23 18:04:30 2005
@@ -99,6 +99,7 @@
   $self->{pristine_headers} =	'';
   $self->{pristine_body} =	'';
   $self->{mime_boundary_state} = {};
+  $self->{line_ending} =	"\n";
 
   bless($self,$class);
 
@@ -168,6 +169,14 @@
       }
       $self->{'mbox_sep'} = "From $address $DAY_OF_WEEK[$arr[6]] $2 $1 $4:$5:$6 $3\n";
     }
+  }
+
+  # bug 4363
+  # Check to see if we should do CRLF instead of just LF
+  # For now, just check the first header and do whatever it does
+  if (@message && $message[0] =~ /\r\n/) {
+    $self->{line_ending} = "\r\n";
+    dbg("message: line ending changed to CRLF");
   }
 
   # Go through all the headers of the message

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/PerMsgStatus.pm
URL: http://svn.apache.org/viewcvs/spamassassin/trunk/lib/Mail/SpamAssassin/PerMsgStatus.pm?rev=327897&r1=327896&r2=327897&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/PerMsgStatus.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/PerMsgStatus.pm Sun Oct 23 18:04:30 2005
@@ -681,13 +681,21 @@
 sub rewrite_mail {
   my ($self) = @_;
 
-  my $mbox = $self->{msg}->get_mbox_separator() || '';
+  my $msg = $self->{msg}->get_mbox_separator() || '';
+
   if ($self->{is_spam} && $self->{conf}->{report_safe}) {
-    return $mbox.$self->rewrite_report_safe();
+    $msg .= $self->rewrite_report_safe();
   }
   else {
-    return $mbox.$self->rewrite_no_report_safe();
+    $msg .= $self->rewrite_no_report_safe();
   }
+
+  # Make the line endings appropriate for the situation
+  if ($self->{msg}->{line_ending} ne "\n") {
+    $msg =~ s/\r?\n/$self->{msg}->{line_ending}/g;
+  }
+
+  return $msg;
 }
 
 # rewrite the message in report_safe mode