- Fix handling of message bodies (quoted-printable encoded) with NULL characters (#1486189)

release-0.6
alecpl 14 years ago
parent d903fb4dd4
commit ad3c273c91

@ -2080,6 +2080,7 @@ class rcube_imap_generic
} }
$bytes -= $len; $bytes -= $len;
// BASE64
if ($mode == 1) { if ($mode == 1) {
$line = rtrim($line, "\t\r\n\0\x0B"); $line = rtrim($line, "\t\r\n\0\x0B");
// create chunks with proper length for base64 decoding // create chunks with proper length for base64 decoding
@ -2092,40 +2093,30 @@ class rcube_imap_generic
} }
else else
$prev = ''; $prev = '';
$line = base64_decode($line);
if ($file) // QUOTED-PRINTABLE
fwrite($file, base64_decode($line));
else if ($print)
echo base64_decode($line);
else
$result .= base64_decode($line);
} else if ($mode == 2) { } else if ($mode == 2) {
$line = rtrim($line, "\t\r\0\x0B"); $line = rtrim($line, "\t\r\0\x0B");
if ($file) $line = quoted_printable_decode($line);
fwrite($file, quoted_printable_decode($line)); // Remove NULL characters (#1486189)
else if ($print) $line = str_replace("\x00", '', $line);
echo quoted_printable_decode($line); // UUENCODE
else
$result .= quoted_printable_decode($line);
} else if ($mode == 3) { } else if ($mode == 3) {
$line = rtrim($line, "\t\r\n\0\x0B"); $line = rtrim($line, "\t\r\n\0\x0B");
if ($line == 'end' || preg_match('/^begin\s+[0-7]+\s+.+$/', $line)) if ($line == 'end' || preg_match('/^begin\s+[0-7]+\s+.+$/', $line))
continue; continue;
if ($file) $line = convert_uudecode($line);
fwrite($file, convert_uudecode($line)); // default
else if ($print)
echo convert_uudecode($line);
else
$result .= convert_uudecode($line);
} else { } else {
$line = rtrim($line, "\t\r\n\0\x0B"); $line = rtrim($line, "\t\r\n\0\x0B") . "\n";
}
if ($file) if ($file)
fwrite($file, $line . "\n"); fwrite($file, $line);
else if ($print) else if ($print)
echo $line . "\n"; echo $line;
else else
$result .= $line . "\n"; $result .= $line;
}
} }
} }

Loading…
Cancel
Save