Ticket #1484442: forward.diff

File forward.diff, 3.6 kB (added by alec, 7 months ago)

update + #1484914 fixes

  • program/steps/mail/compose.inc

    diff -ruN rc-beta3/program/steps/mail/compose.inc rc-beta2/program/steps/mail/compose.inc
    old new  
    522522 
    523523  // add attachments 
    524524  if (!isset($_SESSION['compose']['forward_attachments']) && is_array($MESSAGE->mime_parts)) 
    525     rcmail_write_compose_attachments($MESSAGE); 
     525    rcmail_write_compose_attachments($MESSAGE, $bodyIsHtml); 
    526526     
    527527  return $prefix.$body; 
    528528} 
     
    539539  if (!isset($_SESSION['compose']['forward_attachments']) 
    540540      && is_array($MESSAGE->mime_parts) 
    541541      && count($MESSAGE->mime_parts) > 0) 
    542     rcmail_write_compose_attachments($MESSAGE); 
     542    rcmail_write_compose_attachments($MESSAGE, $bodyIsHtml); 
    543543 
    544544  return $body; 
    545545} 
    546546   
    547547   
    548 function rcmail_write_compose_attachments(&$message) 
     548function rcmail_write_compose_attachments(&$message, $bodyIsHtml) 
    549549{ 
    550550  global $RCMAIL, $IMAP; 
    551551 
     
    556556   
    557557  foreach ((array)$message->mime_parts as $pid => $part) 
    558558  { 
    559     if ($part->ctype_primary != 'message' && 
     559    if (($part->ctype_primary != 'message' || !$bodyIsHtml) && 
    560560        ($part->disposition=='attachment' || $part->disposition=='inline' || $part->headers['content-id'] || 
    561561         (empty($part->disposition) && $part->filename))) 
    562562    { 
  • program/steps/mail/sendmail.inc

    diff -ruN rc-beta3/program/steps/mail/sendmail.inc rc-beta2/program/steps/mail/sendmail.inc
    old new  
    266266  $MAIL_MIME->setTXTBody($message_body, FALSE, TRUE); 
    267267  } 
    268268 
     269// chose transfer encoding 
     270$charset_7bit = array('ASCII', 'ISO-2022-JP', 'ISO-8859-1', 'ISO-8859-2', 'ISO-8859-15'); 
     271$transfer_encoding = in_array(strtoupper($message_charset), $charset_7bit) ? '7bit' : '8bit'; 
    269272 
    270273// add stored attachments, if any 
    271274if (is_array($_SESSION['compose']['attachments'])) 
     
    285288        We need to replace mime_content_type in a later release because the function 
    286289        is deprecated in favour of File_Info 
    287290      */ 
     291      $ctype = rc_mime_content_type($attachment['path'], $attachment['mimetype']); 
     292      $ctype = str_replace('image/pjpeg', 'image/jpeg', $ctype); // #1484914 
     293 
     294      // .eml attachments send inline 
    288295      $MAIL_MIME->addAttachment($attachment['path'], 
    289         rc_mime_content_type($attachment['path'], $attachment['mimetype']), 
    290         $attachment['name'], true, 'base64', 
    291         'attachment', $message_charset); 
     296        $ctype,  
     297        $attachment['name'], true,  
     298        ($ctype == 'message/rfc822' ? $transfer_encoding : 'base64'), 
     299        ($ctype == 'message/rfc822' ? 'inline' : 'attachment'), 
     300        $message_charset); 
    292301    } 
    293302  } 
    294303 
    295304// add submitted attachments 
    296305if (is_array($_FILES['_attachments']['tmp_name'])) 
    297306  foreach ($_FILES['_attachments']['tmp_name'] as $i => $filepath) 
    298     $MAIL_MIME->addAttachment($filepath, $files['type'][$i], $files['name'][$i], true, 'base64', 'attachment', $message_charset); 
    299  
     307    { 
     308    $ctype = $files['type'][$i]; 
     309    $ctype = str_replace('image/pjpeg', 'image/jpeg', $ctype); // #1484914 
     310     
     311    $MAIL_MIME->addAttachment($filepath, $ctype, $files['name'][$i], true, 
     312        ($ctype == 'message/rfc822' ? $transfer_encoding : 'base64'), 
     313        'attachment', $message_charset); 
     314    } 
    300315 
    301 // chose transfer encoding 
    302 $charset_7bit = array('ASCII', 'ISO-2022-JP', 'ISO-8859-1', 'ISO-8859-2', 'ISO-8859-15'); 
    303 $transfer_encoding = in_array(strtoupper($message_charset), $charset_7bit) ? '7bit' : '8bit'; 
    304316 
    305317// encoding settings for mail composing 
    306318$MAIL_MIME->setParam(array(