diff options
| author | alec <alec@208e9e7b-5314-0410-a742-e7e81cd9613c> | 2009-02-06 19:04:45 +0000 |
|---|---|---|
| committer | alec <alec@208e9e7b-5314-0410-a742-e7e81cd9613c> | 2009-02-06 19:04:45 +0000 |
| commit | a33b4bc903acdbb08e369f4a2c79c0a69f2a49b0 (patch) | |
| tree | 6fe40ff783044a2583cf42ec63d8b7cbe7546161 /roundcubemail/program/lib | |
| parent | 8741945860c3d2fbbd46842dd0039398b228127e (diff) | |
- Fix some base64 encoded attachments handling (#1485725)
git-svn-id: https://svn.roundcube.net/trunk@2280 208e9e7b-5314-0410-a742-e7e81cd9613c
Diffstat (limited to 'roundcubemail/program/lib')
| -rw-r--r-- | roundcubemail/program/lib/imap.inc | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/roundcubemail/program/lib/imap.inc b/roundcubemail/program/lib/imap.inc index 302cfc007..056632209 100644 --- a/roundcubemail/program/lib/imap.inc +++ b/roundcubemail/program/lib/imap.inc @@ -2508,7 +2508,8 @@ function iil_C_HandlePartBody(&$conn, $mailbox, $id, $part='', $mode=1, $file=NU $len = $to - $from; $sizeStr = substr($line, $from, $len); $bytes = (int)$sizeStr; - + $prev = ''; + while ($bytes > 0) { $line = iil_ReadLine($fp, 1024); $len = strlen($line); @@ -2518,14 +2519,27 @@ function iil_C_HandlePartBody(&$conn, $mailbox, $id, $part='', $mode=1, $file=NU } $bytes -= strlen($line); + $line = rtrim($line, "\t\r\n\0\x0B"); + if ($mode == 1) { if ($file) - fwrite($file, rtrim($line, "\t\r\n\0\x0B") . "\n"); + fwrite($file, $line . "\n"); else - $result .= rtrim($line, "\t\r\n\0\x0B") . "\n"; + $result .= $line . "\n"; } else if ($mode == 2) { - echo rtrim($line, "\t\r\n\0\x0B") . "\n"; + echo $line . "\n"; } else if ($mode == 3) { + // create chunks with proper length for base64 decoding + $line = $prev.$line; + $length = strlen($line); + if ($length % 4) { + $length = floor($length / 4) * 4; + $prev = substr($line, $length); + $line = substr($line, 0, $length); + } + else + $prev = ''; + if ($file) fwrite($file, base64_decode($line)); else |
