Changeset 3963 in subversion


Ignore:
Timestamp:
Sep 14, 2010 5:53:53 AM (3 years ago)
Author:
alec
Message:
  • Improve logic of signatures colorizing and truncating, introduce sig_max_lines option
Location:
trunk/roundcubemail/program/steps/mail
Files:
2 edited

Legend:

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

    r3949 r3963  
    611611 
    612612  if (!$bodyIsHtml) { 
     613    $body = preg_replace('/\r?\n/', "\n", $body); 
     614   
    613615    // try to remove the signature 
    614     if ($RCMAIL->config->get('strip_existing_sig', true) && ($sp = strrpos($body, '-- ')) !== false && ($sp == 0 || $body{$sp-1} == "\n")) { 
    615       if ($body{$sp+3}==' ' || $body{$sp+3}=="\n" || $body{$sp+3}=="\r") 
    616         $body = substr($body, 0, max(0, $sp-1)); 
     616    if ($RCMAIL->config->get('strip_existing_sig', true)) { 
     617      $len = strlen($body); 
     618      while (($sp = strrpos($body, "-- \n", $sp ? -$len+$sp-1 : 0)) !== false) { 
     619        if ($sp == 0 || $body[$sp-1] == "\n") { 
     620          // do not touch blocks with more that X lines 
     621          if (substr_count($body, "\n", $sp) < $RCMAIL->config->get('sig_max_lines', 15)) { 
     622            $body = substr($body, 0, max(0, $sp-1)); 
     623          } 
     624          break; 
     625        } 
     626      } 
    617627    } 
    618628 
    619629    // soft-wrap and quote message text 
    620     $body = rcmail_wrap_and_quote(rtrim($body, "\r\n"), $LINE_LENGTH); 
     630    $body = rcmail_wrap_and_quote(rtrim($body, "\n"), $LINE_LENGTH); 
    621631 
    622632    // add title line(s) 
  • trunk/roundcubemail/program/steps/mail/func.inc

    r3962 r3963  
    755755function rcmail_plain_body($body, $flowed=false) 
    756756{ 
     757  global $RCMAIL; 
     758 
    757759  // make links and email-addresses clickable 
    758760  $replacer = new rcube_string_replacer; 
     
    781783      else if ($flowed) { 
    782784        // previous line is flowed 
    783         if (isset($a_lines[$last]) 
     785        if (isset($a_lines[$last]) && $a_lines[$n] 
    784786          && $a_lines[$last][strlen($a_lines[$last])-1] == ' ') { 
    785           // merge lines (and remove space-stuffing) 
     787          // merge lines 
    786788          $a_lines[$last] .= $a_lines[$n]; 
    787789          unset($a_lines[$n]); 
     
    804806 
    805807          // previous line is flowed? 
    806           if (isset($a_lines[$last]) 
     808          if (isset($a_lines[$last]) && $a_lines[$n] 
    807809            && $a_lines[$last] != '-- ' 
    808810            && $a_lines[$last][strlen($a_lines[$last])-1] == ' ' 
     
    831833 
    832834  // colorize signature 
    833   if (($sp = strrpos($body, "-- \n")) !== false) { 
    834     if (($sp == 0 || $body[$sp-1] == "\n")) { 
    835       // do not touch blocks with more that 10 lines 
    836       if (substr_count($body, "\n", $sp) < 10) 
     835  $len = strlen($body); 
     836  while (($sp = strrpos($body, "-- \n", $sp ? -$len+$sp-1 : 0)) !== false) { 
     837    if ($sp == 0 || $body[$sp-1] == "\n") { 
     838      // do not touch blocks with more that X lines 
     839      if (substr_count($body, "\n", $sp) < $RCMAIL->config->get('sig_max_lines', 15)) 
    837840        $body = substr($body, 0, max(0, $sp)) 
    838841          .'<span class="sig">'.substr($body, $sp).'</span>'; 
     842      break; 
    839843    } 
    840844  } 
Note: See TracChangeset for help on using the changeset viewer.