Changeset 4077 in subversion


Ignore:
Timestamp:
Oct 12, 2010 4:56:46 AM (3 years ago)
Author:
alec
Message:
  • Fix signature removal when replying in HTML to plain/text message
Location:
trunk/roundcubemail/program/steps/mail
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/roundcubemail/program/steps/mail/compose.inc

    r4059 r4077  
    538538      } 
    539539      else { 
    540         $body = rcmail_plain_body($MESSAGE->first_text_part()); 
     540        $body = $MESSAGE->first_text_part(); 
     541        // try to remove the signature 
     542        if ($RCMAIL->config->get('strip_existing_sig', true)) 
     543          $body = rcmail_remove_signature($body); 
     544        // add HTML formatting 
     545        $body = rcmail_plain_body($body); 
    541546        if ($body) 
    542547          $body = '<pre>' . $body . '</pre>'; 
     
    711716 
    712717    // try to remove the signature 
    713     if ($RCMAIL->config->get('strip_existing_sig', true)) { 
    714       $len = strlen($body); 
    715       while (($sp = strrpos($body, "-- \n", $sp ? -$len+$sp-1 : 0)) !== false) { 
    716         if ($sp == 0 || $body[$sp-1] == "\n") { 
    717           // do not touch blocks with more that X lines 
    718           if (substr_count($body, "\n", $sp) < $RCMAIL->config->get('sig_max_lines', 15)) { 
    719             $body = substr($body, 0, max(0, $sp-1)); 
    720           } 
    721           break; 
    722         } 
    723       } 
    724     } 
     718    if ($RCMAIL->config->get('strip_existing_sig', true)) 
     719      $body = rcmail_remove_signature($body); 
    725720 
    726721    // soft-wrap and quote message text 
     
    836831  return $body; 
    837832} 
    838    
    839    
     833 
     834 
     835function rcmail_remove_signature($body) 
     836{ 
     837  global $RCMAIL; 
     838 
     839  $len = strlen($body); 
     840  $sig_max_lines = $RCMAIL->config->get('sig_max_lines', 15); 
     841 
     842  while (($sp = strrpos($body, "-- \n", $sp ? -$len+$sp-1 : 0)) !== false) { 
     843    if ($sp == 0 || $body[$sp-1] == "\n") { 
     844      // do not touch blocks with more that X lines 
     845      if (substr_count($body, "\n", $sp) < $sig_max_lines) { 
     846        $body = substr($body, 0, max(0, $sp-1)); 
     847      } 
     848      break; 
     849    } 
     850  } 
     851 
     852  return $body; 
     853} 
     854 
     855 
    840856function rcmail_write_compose_attachments(&$message, $bodyIsHtml) 
    841857{ 
  • trunk/roundcubemail/program/steps/mail/func.inc

    r4063 r4077  
    844844  $body = Q(join("\n", $a_lines), 'dummy', false); 
    845845 
    846   // colorize signature 
     846  // colorize signature (up to <sig_max_lines> lines) 
    847847  $len = strlen($body); 
     848  $sig_max_lines = $RCMAIL->config->get('sig_max_lines', 15); 
    848849  while (($sp = strrpos($body, "-- \n", $sp ? -$len+$sp-1 : 0)) !== false) { 
    849850    if ($sp == 0 || $body[$sp-1] == "\n") { 
    850851      // do not touch blocks with more that X lines 
    851       if (substr_count($body, "\n", $sp) < $RCMAIL->config->get('sig_max_lines', 15)) 
     852      if (substr_count($body, "\n", $sp) < $sig_max_lines) 
    852853        $body = substr($body, 0, max(0, $sp)) 
    853854          .'<span class="sig">'.substr($body, $sp).'</span>'; 
Note: See TracChangeset for help on using the changeset viewer.