- Support UUencode content encoding (#1485839)
| | |
| | | CHANGELOG RoundCube Webmail |
| | | =========================== |
| | | |
| | | - Support UUencode content encoding (#1485839) |
| | | - Minimize chance of race condition in session handling (#1485659, #1484678) |
| | | - Fix session handling on non-session SQL query error (#1485734) |
| | | - Fix html editor mode setting when reopening draft message (#1485834) |
| | |
| | | |
| | | if (!$part) $part = 'TEXT'; |
| | | |
| | | if ($print) |
| | | { |
| | | $mode = $o_part->encoding == 'base64' ? 3 : ($o_part->encoding == 'quoted-printable' ? 1 : 2); |
| | | $body = iil_C_HandlePartBody($this->conn, $this->mailbox, $msg_id, $part, $mode); |
| | | $body = iil_C_HandlePartBody($this->conn, $this->mailbox, $msg_id, $part, |
| | | $o_part->encoding, $print, $fp); |
| | | |
| | | // we have to decode the part manually before printing |
| | | if ($mode == 1) |
| | | { |
| | | echo $this->mime_decode($body, $o_part->encoding); |
| | | $body = true; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | if ($fp && $o_part->encoding == 'base64') |
| | | return iil_C_HandlePartBody($this->conn, $this->mailbox, $msg_id, $part, 3, $fp); |
| | | else |
| | | $body = iil_C_HandlePartBody($this->conn, $this->mailbox, $msg_id, $part, 1); |
| | | |
| | | // decode part body |
| | | if ($o_part->encoding) |
| | | $body = $this->mime_decode($body, $o_part->encoding); |
| | | if ($fp || $print) |
| | | return true; |
| | | |
| | | // convert charset (if text or message part) |
| | | if ($o_part->ctype_primary=='text' || $o_part->ctype_primary=='message') |
| | | { |
| | | if ($o_part->ctype_primary=='text' || $o_part->ctype_primary=='message') { |
| | | // assume default if no charset specified |
| | | if (empty($o_part->charset)) |
| | | $o_part->charset = $this->default_charset; |
| | | |
| | | $body = rcube_charset_convert($body, $o_part->charset); |
| | | } |
| | | |
| | | if ($fp) |
| | | { |
| | | fwrite($fp, $body); |
| | | return true; |
| | | } |
| | | } |
| | | |
| | | return $body; |
| | |
| | | function &get_body($uid, $part=1) |
| | | { |
| | | $headers = $this->get_headers($uid); |
| | | return rcube_charset_convert( |
| | | $this->mime_decode($this->get_message_part($uid, $part), 'quoted-printable'), |
| | | return rcube_charset_convert($this->get_message_part($uid, $part, NULL), |
| | | $headers->charset ? $headers->charset : $this->default_charset); |
| | | } |
| | | |
| | |
| | | if (!($msg_id = $this->_uid2id($uid))) |
| | | return FALSE; |
| | | |
| | | iil_C_HandlePartBody($this->conn, $this->mailbox, $msg_id, NULL, 2); |
| | | iil_C_HandlePartBody($this->conn, $this->mailbox, $msg_id, NULL, NULL, true); |
| | | } |
| | | |
| | | |
| | |
| | | { |
| | | switch (strtolower($encoding)) |
| | | { |
| | | case '7bit': |
| | | return $input; |
| | | break; |
| | | |
| | | case 'quoted-printable': |
| | | return quoted_printable_decode($input); |
| | | break; |
| | |
| | | return base64_decode($input); |
| | | break; |
| | | |
| | | case 'x-uuencode': |
| | | case 'x-uue': |
| | | case 'uue': |
| | | case 'uuencode': |
| | | return convert_uudecode($input); |
| | | break; |
| | | |
| | | case '7bit': |
| | | default: |
| | | return $input; |
| | | } |
| | |
| | | |
| | | $part = empty($part) ? 'HEADER' : $part.'.MIME'; |
| | | |
| | | return iil_C_HandlePartBody($conn, $mailbox, $id, $part, 1); |
| | | return iil_C_HandlePartBody($conn, $mailbox, $id, $part); |
| | | } |
| | | |
| | | function iil_C_HandlePartBody(&$conn, $mailbox, $id, $part='', $mode=1, $file=NULL) { |
| | | /* modes: |
| | | 1: return string (or write to $file pointer) |
| | | 2: print |
| | | 3: base64 and print (or write to $file pointer) |
| | | */ |
| | | function iil_C_HandlePartBody(&$conn, $mailbox, $id, $part='', $encoding=NULL, $print=NULL, $file=NULL) { |
| | | |
| | | $fp = $conn->fp; |
| | | $result = false; |
| | | |
| | | switch ($encoding) { |
| | | case 'base64': |
| | | $mode = 1; |
| | | break; |
| | | case 'quoted-printable': |
| | | $mode = 2; |
| | | break; |
| | | case 'x-uuencode': |
| | | case 'x-uue': |
| | | case 'uue': |
| | | case 'uuencode': |
| | | $mode = 3; |
| | | break; |
| | | default: |
| | | $mode = 0; |
| | | } |
| | | |
| | | if (iil_C_Select($conn, $mailbox)) { |
| | | $reply_key = '* ' . $id; |
| | | |
| | | // format request |
| | | $key = 'ftch' . ($c++) . ' '; |
| | | $key = 'ftch0'; |
| | | $request = $key . "FETCH $id (BODY.PEEK[$part])"; |
| | | // send request |
| | | if (!iil_PutLine($fp, $request)) { |
| | |
| | | $result = substr($line, $from, $len); |
| | | } |
| | | |
| | | if ($mode == 2) { |
| | | echo $result; |
| | | } else if ($mode == 3) { |
| | | if ($file) |
| | | fwrite($file, base64_decode($result)); |
| | | else |
| | | echo base64_decode($result); |
| | | } |
| | | if ($mode == 1) |
| | | $result = base64_decode($result); |
| | | else if ($mode == 2) |
| | | $result = quoted_printable_decode($result); |
| | | else if ($mode == 3) |
| | | $result = convert_uudecode($result); |
| | | |
| | | } else if ($line[$len-1] == '}') { |
| | | //multi-line request, find sizes of content and receive that many bytes |
| | | $from = strpos($line, '{') + 1; |
| | |
| | | $line = rtrim($line, "\t\r\n\0\x0B"); |
| | | |
| | | if ($mode == 1) { |
| | | if ($file) |
| | | fwrite($file, $line . "\n"); |
| | | else |
| | | $result .= $line . "\n"; |
| | | } else if ($mode == 2) { |
| | | echo $line . "\n"; |
| | | } else if ($mode == 3) { |
| | | // create chunks with proper length for base64 decoding |
| | | $line = $prev.$line; |
| | | $length = strlen($line); |
| | |
| | | |
| | | if ($file) |
| | | fwrite($file, base64_decode($line)); |
| | | else |
| | | else if ($print) |
| | | echo base64_decode($line); |
| | | else |
| | | $result .= base64_decode($line); |
| | | } else if ($mode == 2) { |
| | | $line .= $line[sizeof($line)-1] != '=' ? "\n" : ''; |
| | | if ($file) |
| | | fwrite($file, quoted_printable_decode($line)); |
| | | else if ($print) |
| | | echo quoted_printable_decode($line); |
| | | else |
| | | $result .= quoted_printable_decode($line); |
| | | } else if ($mode == 3) { |
| | | if ($file) |
| | | fwrite($file, convert_uudecode($line)); |
| | | else if ($print) |
| | | echo convert_uudecode($line); |
| | | else |
| | | $result .= convert_uudecode($line); |
| | | } else { |
| | | if ($file) |
| | | fwrite($file, $line . "\n"); |
| | | else if ($print) |
| | | echo $line . "\n"; |
| | | else |
| | | $result .= $line . "\n"; |
| | | } |
| | | } |
| | | } |
| | |
| | | $line = iil_ReadLine($fp, 1024); |
| | | } while (!iil_StartsWith($line, $key, true)); |
| | | |
| | | if ($mode == 3 && $file) { |
| | | return true; |
| | | } |
| | | |
| | | if ($result) { |
| | | $result = rtrim($result, "\t\r\n\0\x0B"); |
| | | if ($file) { |
| | | fwrite($file, $result); |
| | | return true; |
| | | } |
| | | } else if ($print) { |
| | | echo $result; |
| | | } else |
| | | return $result; // substr($result, 0, strlen($result)-1); |
| | | } |
| | | |
| | | return false; |
| | | } |
| | | |
| | | if ($mode==1) { |
| | | if ($file && $result) { |
| | | fwrite($file, $result); |
| | | return true; |
| | | } |
| | | return $result; |
| | | } |
| | | |
| | | return false; |
| | | } |
| | | |
| | | function iil_C_FetchPartBody(&$conn, $mailbox, $id, $part, $file=NULL) { |
| | | return iil_C_HandlePartBody($conn, $mailbox, $id, $part, 1, $file); |
| | | return iil_C_HandlePartBody($conn, $mailbox, $id, $part, NULL, NULL, $file); |
| | | } |
| | | |
| | | function iil_C_PrintPartBody(&$conn, $mailbox, $id, $part) { |
| | | iil_C_HandlePartBody($conn, $mailbox, $id, $part, 2); |
| | | } |
| | | |
| | | function iil_C_PrintBase64Body(&$conn, $mailbox, $id, $part) { |
| | | iil_C_HandlePartBody($conn, $mailbox, $id, $part, 3); |
| | | iil_C_HandlePartBody($conn, $mailbox, $id, $part, NULL, true, NULL); |
| | | } |
| | | |
| | | function iil_C_CreateFolder(&$conn, $folder) { |
| | |
| | | } |
| | | } |
| | | return $result; |
| | | } |
| | | |
| | | function iil_C_PrintSource(&$conn, $folder, $id, $part) { |
| | | $header = iil_C_FetchPartHeader($conn, $folder, $id, $part); |
| | | //echo str_replace("\r", '', $header); |
| | | echo $header; |
| | | echo iil_C_PrintPartBody($conn, $folder, $id, $part); |
| | | } |
| | | |
| | | function iil_C_GetQuota(&$conn) { |