diff options
author | alecpl <alec@alec.pl> | 2010-11-10 08:15:41 +0000 |
---|---|---|
committer | alecpl <alec@alec.pl> | 2010-11-10 08:15:41 +0000 |
commit | ad3c273c91ecdae72e14e03a4bc4220d0ebdfa41 (patch) | |
tree | e544372ba64f9836282dd7ea7bb83454fdde8580 /program/include/rcube_imap_generic.php | |
parent | d903fb4dd437423f32054abd5b2164b261776555 (diff) |
- Fix handling of message bodies (quoted-printable encoded) with NULL characters (#1486189)
Diffstat (limited to 'program/include/rcube_imap_generic.php')
-rw-r--r-- | program/include/rcube_imap_generic.php | 43 |
1 files changed, 17 insertions, 26 deletions
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; } } |