Changeset 6b6f2e8 in github for program/include/rcube_message.php


Ignore:
Timestamp:
May 20, 2010 5:28:30 PM (3 years ago)
Author:
thomascube <thomas@…>
Branches:
master, HEAD, courier-fix, dev-browser-capabilities, pdo, release-0.6, release-0.7, release-0.8
Children:
8ad5c89
Parents:
e93c72d9
Message:

Display and send messages with format=flowed (#1484370), fixes word wrapping issues (#1486543)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • program/include/rcube_message.php

    rc1439f9 r6b6f2e8  
    199199      if ($mimetype == 'text/plain') { 
    200200        $out = $this->imap->get_message_part($this->uid, $mime_id, $part); 
     201         
     202        // re-format format=flowed content 
     203        if ($part->ctype_secondary == "plain" && $part->ctype_parameters['format'] == "flowed") 
     204          $out = self::unfold_flowed($out); 
    201205        break; 
    202206      } 
     
    478482 
    479483 
     484  /** 
     485   * Interpret a format=flowed message body according to RFC 2646 
     486   * 
     487   * @param string  Raw body formatted as flowed text 
     488   * @return string Interpreted text with unwrapped lines and stuffed space removed 
     489   */ 
     490  public static function unfold_flowed($text) 
     491  { 
     492    return preg_replace( 
     493      array('/-- (\r?\n)/',   '/^ /m',  '/(.) \r?\n/',  '/--%SIGEND%(\r?\n)/'), 
     494      array('--%SIGEND%\\1',  '',       '\\1 ',         '-- \\1'), 
     495      $text); 
     496  } 
     497   
     498  /** 
     499   * Wrap the given text to comply with RFC 2646 
     500   */ 
     501  public static function format_flowed($text, $length = 72) 
     502  { 
     503    $out = ''; 
     504     
     505    foreach (preg_split('/\r?\n/', trim($text)) as $line) { 
     506      // don't wrap quoted lines (to avoid wrapping problems) 
     507      if ($line[0] != '>') 
     508        $line = rc_wordwrap(rtrim($line), $length - 1, " \r\n"); 
     509 
     510      $out .= $line . "\r\n"; 
     511    } 
     512     
     513    return $out; 
     514  } 
     515 
    480516} 
    481517 
Note: See TracChangeset for help on using the changeset viewer.