Ticket #1484560: bugfix1484560.patch

File bugfix1484560.patch, 1.8 kB (added by bvanheuverzwijn, 9 months ago)

Patch to fix the bug

  • trunk/roundcubemail/program/steps/mail/func.inc

     
    680680    $convert_replaces[] = "rcmail_str_replacement('<a href=\"mailto:\\1\" onclick=\"return ".JS_OBJECT_NAME.".command(\'compose\',\'\\1\',this)\">\\1</a>', \$replace_strings)"; 
    681681     
    682682    if ($part->ctype_parameters['format'] != 'flowed') 
    683       $body = wordwrap(trim($body), 80); 
     683    { 
     684      // Rebuild the message body with a maximum of 80 chars, while keeping 
     685      // quoted message. 
     686      $lines = preg_split('/\r?\n/', trim($body)); 
     687      $body = ''; 
     688       
     689      foreach ($lines as $line) 
     690      { 
     691        if (strlen($line) > 80) 
     692        { 
     693          if (preg_match('/^(>+\s*)+/', $line, $regs)) 
     694          { 
     695            $length = strlen($regs[0]); 
     696            $prefix = substr($line, 0, $length); 
     697             
     698            // Remove '> ' from the line, then wordwrap() the line 
     699            $line = substr($line, $length); 
     700            $line = wordwrap($line, 80 - $length); 
     701             
     702            // Rebuild the line with '> ' at the beginning of each 'subline' 
     703            $newline = ''; 
     704            $line = explode("\n", $line); 
     705             
     706            foreach ($line as $l) 
     707            { 
     708              $newline .= $prefix.$l."\n"; 
     709            } 
     710             
     711            // Remove the righest newline char 
     712            $line = rtrim($newline); 
     713          } 
     714          else 
     715          { 
     716            $line = wordwrap($line, 80); 
     717          } 
     718        } 
     719         
     720        // Append the line 
     721        $body .= $line."\n"; 
     722      } 
     723    } 
    684724 
    685725    $body = preg_replace($convert_patterns, $convert_replaces, $body); 
    686726