[Mimedefang] [PATCH] Spamassassin fix for mails with masses of newlines
Martin Blapp
mb at imp.ch
Thu Sep 16 06:56:22 EDT 2004
Hi all,
The patch below reduces the mem usage of SA with a 200K mail
to almost 1/3 of it's previous usage. Instead of 210MB it only uses
here 80MB. You will only see an effect if a mail has many newlines.
Martin
--- lib/Mail/SpamAssassin/Message.pm Thu Sep 9 20:29:19 2004
+++ lib/Mail/SpamAssassin/Message.pm Thu Sep 16 12:50:54 2004
@@ -197,10 +197,14 @@
# will get modified below
$self->{'pristine_body'} = join('', @message);
- # CRLF -> LF
- for ( @message ) {
- s/\r\n/\n/;
- }
+ # Remove repeated empty lines and convert CRLF to LF
+ # This saves us a lot of mem.
+ my $tmpmsg = join('', $self->{'pristine_body'});
+ $tmpmsg =~ s/\r\n/\n/gs;
+ $tmpmsg =~ s/\n{100,}/\n/gs;
+ @message = split ( /^/m, $tmpmsg );
+
+ $self->{'pristine_body'} = join('', @message);
# If the message does need to get parsed, save off a copy of the body
# in a format we can easily parse later so we don't have to rip from
Martin Blapp, <mb at imp.ch> <mbr at FreeBSD.org>
------------------------------------------------------------------
ImproWare AG, UNIXSP & ISP, Zurlindenstrasse 29, 4133 Pratteln, CH
Phone: +41 61 826 93 00 Fax: +41 61 826 93 01
PGP: <finger -l mbr at freebsd.org>
PGP Fingerprint: B434 53FC C87C FE7B 0A18 B84C 8686 EF22 D300 551E
------------------------------------------------------------------
More information about the MIMEDefang
mailing list