Mailing List Archive

svn commit: r492375 - /spamassassin/trunk/lib/Mail/SpamAssassin/Util.pm
Author: felicity
Date: Wed Jan 3 17:00:57 2007
New Revision: 492375

URL: http://svn.apache.org/viewvc?view=rev&rev=492375
Log:
bug 5272: the new Util::wrap() function didn't properly allow the first entry on the line to overflow if overflow == 0, causing an infinite (or until OOM) loop. :(

Modified:
spamassassin/trunk/lib/Mail/SpamAssassin/Util.pm

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Util.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/Util.pm?view=diff&rev=492375&r1=492374&r2=492375
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Util.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Util.pm Wed Jan 3 17:00:57 2007
@@ -533,10 +533,11 @@
my @arr = split(/($break)/, $string);

# tack the first prefix line at the start
- splice @arr, 0, 0, $first;
+ splice @arr, 0, 0, $first if $first;

# go ahead and make up the lines in the array
my $pos = 0;
+ my $pos_mod = 0;
while ($#arr > $pos) {
my $len = length $arr[$pos];

@@ -544,7 +545,8 @@
# need to verify what will happen with the next line. if we don't
# care if a single line goes longer, don't care about the next
# line.
- if ($overflow == 0) {
+ # we also want this to be true for the first entry on the line
+ if ($pos_mod != 0 && $overflow == 0) {
$len += length $arr[$pos+1];
}

@@ -552,16 +554,18 @@
# if the length determined above is within bounds, go ahead and
# merge the next line with the current one
$arr[$pos] .= splice @arr, $pos+1, 1;
+ $pos_mod = 1;
}
else {
# ok, the current line is the right length, but there's more text!
# prep the current line and then go onto the next one

# strip any trailing whitespace from the next line that's ready
- $arr[0] =~ s/\s+$//;
+ $arr[$pos] =~ s/\s+$//;

- # go to the next line
+ # go to the next line and reset pos_mod
$pos++;
+ $pos_mod = 0;

# put the appropriate prefix at the front of the line
splice @arr, $pos, 0, $prefix;