From ad3c273c91ecdae72e14e03a4bc4220d0ebdfa41 Mon Sep 17 00:00:00 2001 From: alecpl Date: Wed, 10 Nov 2010 08:15:41 +0000 Subject: - Fix handling of message bodies (quoted-printable encoded) with NULL characters (#1486189) --- program/include/rcube_imap_generic.php | 43 ++++++++++++++-------------------- 1 file changed, 17 insertions(+), 26 deletions(-) (limited to 'program') diff --git a/program/include/rcube_imap_generic.php b/program/include/rcube_imap_generic.php index 56f30aa81..864c57193 100644 --- a/program/include/rcube_imap_generic.php +++ b/program/include/rcube_imap_generic.php @@ -2080,6 +2080,7 @@ class rcube_imap_generic } $bytes -= $len; + // BASE64 if ($mode == 1) { $line = rtrim($line, "\t\r\n\0\x0B"); // create chunks with proper length for base64 decoding @@ -2092,40 +2093,30 @@ class rcube_imap_generic } else $prev = ''; - - if ($file) - fwrite($file, base64_decode($line)); - else if ($print) - echo base64_decode($line); - else - $result .= base64_decode($line); + $line = base64_decode($line); + // QUOTED-PRINTABLE } else if ($mode == 2) { $line = rtrim($line, "\t\r\0\x0B"); - if ($file) - fwrite($file, quoted_printable_decode($line)); - else if ($print) - echo quoted_printable_decode($line); - else - $result .= quoted_printable_decode($line); + $line = quoted_printable_decode($line); + // Remove NULL characters (#1486189) + $line = str_replace("\x00", '', $line); + // UUENCODE } else if ($mode == 3) { $line = rtrim($line, "\t\r\n\0\x0B"); if ($line == 'end' || preg_match('/^begin\s+[0-7]+\s+.+$/', $line)) continue; - if ($file) - fwrite($file, convert_uudecode($line)); - else if ($print) - echo convert_uudecode($line); - else - $result .= convert_uudecode($line); + $line = convert_uudecode($line); + // default } else { - $line = rtrim($line, "\t\r\n\0\x0B"); - if ($file) - fwrite($file, $line . "\n"); - else if ($print) - echo $line . "\n"; - else - $result .= $line . "\n"; + $line = rtrim($line, "\t\r\n\0\x0B") . "\n"; } + + if ($file) + fwrite($file, $line); + else if ($print) + echo $line; + else + $result .= $line; } } -- cgit v1.2.3