Changeset 3644 in subversion
- Timestamp:
- May 20, 2010 5:28:30 PM (3 years ago)
- Location:
- trunk/roundcubemail
- Files:
-
- 6 edited
-
CHANGELOG (modified) (1 diff)
-
config/main.inc.php.dist (modified) (3 diffs)
-
program/include/rcube_message.php (modified) (2 diffs)
-
program/steps/mail/compose.inc (modified) (2 diffs)
-
program/steps/mail/func.inc (modified) (3 diffs)
-
program/steps/mail/sendmail.inc (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/roundcubemail/CHANGELOG
r3640 r3644 2 2 =========================== 3 3 4 - Read and send messages with format=flowed (#1484370), fixes word wrapping issues (#1486543) 4 5 - Fix duplicated attachments when forwarding a message (#1486487) 5 6 - Fix message/rfc822 attachments containing only attachments are not parsed properly (#1486743) -
trunk/roundcubemail/config/main.inc.php.dist
r3520 r3644 6 6 | | 7 7 | This file is part of the RoundCube Webmail client | 8 | Copyright (C) 2005-20 09, RoundCube Dev. - Switzerland |8 | Copyright (C) 2005-2010, RoundCube Dev. - Switzerland | 9 9 | Licensed under the GNU GPL | 10 10 | | … … 189 189 190 190 // add this user-agent to message headers when sending 191 $rcmail_config['useragent'] = 'Round Cube Webmail/'.RCMAIL_VERSION;191 $rcmail_config['useragent'] = 'Roundcube Webmail/'.RCMAIL_VERSION; 192 192 193 193 // use this name to compose page titles 194 $rcmail_config['product_name'] = 'Round Cube Webmail';194 $rcmail_config['product_name'] = 'Roundcube Webmail'; 195 195 196 196 // try to load host-specific configuration … … 214 214 // leave empty for auto-detection 215 215 $rcmail_config['mail_header_delimiter'] = NULL; 216 217 // number of chars allowed for line when wrapping text. 218 // text wrapping is done when composing/sending messages 219 $rcmail_config['line_length'] = 66; 220 221 // send plaintext messages as format=flowed 222 $rcmail_config['send_format_flowed'] = true; 216 223 217 224 // session domain: .example.org -
trunk/roundcubemail/program/include/rcube_message.php
r3639 r3644 199 199 if ($mimetype == 'text/plain') { 200 200 $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); 201 205 break; 202 206 } … … 478 482 479 483 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 480 516 } 481 517 -
trunk/roundcubemail/program/steps/mail/compose.inc
r3640 r3644 135 135 136 136 // set line length for body wrapping 137 $LINE_LENGTH = $RCMAIL->config->get('line_length', 7 5);137 $LINE_LENGTH = $RCMAIL->config->get('line_length', 72); 138 138 139 139 if (!empty($msg_uid)) … … 598 598 } 599 599 600 // soft-wrap message first 601 $body = rcmail_wrap_quoted($body, $LINE_LENGTH); 602 603 $body = rtrim($body, "\r\n"); 604 605 if ($body) { 606 // split body into single lines 607 $a_lines = preg_split('/\r?\n/', $body); 608 609 // add > to each line 610 for ($n=0; $n<sizeof($a_lines); $n++) { 611 if (strpos($a_lines[$n], '>')===0) 612 $a_lines[$n] = '>'.$a_lines[$n]; 613 else 614 $a_lines[$n] = '> '.$a_lines[$n]; 615 } 616 617 $body = join("\n", $a_lines); 618 } 600 // soft-wrap and quote message text 601 $body = rcmail_wrap_and_quote(rtrim($body, "\r\n"), $LINE_LENGTH); 619 602 620 603 // add title line(s) 621 $prefix = rc_wordwrap(sprintf("On %s, %s wrote:\n",604 $prefix = sprintf("On %s, %s wrote:\n", 622 605 $MESSAGE->headers->date, 623 $MESSAGE->get_header('from')) , $LINE_LENGTH);606 $MESSAGE->get_header('from')); 624 607 625 608 $suffix = ''; -
trunk/roundcubemail/program/steps/mail/func.inc
r3627 r3644 933 933 if (!isset($part->body)) 934 934 $part->body = $MESSAGE->get_part_content($part->mime_id); 935 936 // re-format format=flowed content 937 if ($part->ctype_secondary == "plain" && $part->ctype_parameters['format'] == "flowed") 938 $part->body = rcube_message::unfold_flowed($part->body); 935 939 936 940 $body = rcmail_print_body($part, array('safe' => $safe_mode, 'plain' => !$CONFIG['prefer_html'])); … … 1162 1166 /** 1163 1167 * Wrap text to a given number of characters per line 1164 * but respect the mail quotation of replies messages (>) 1168 * but respect the mail quotation of replies messages (>). 1169 * Finally add another quotation level by prpending the lines 1170 * with > 1165 1171 * 1166 1172 * @param string Text to wrap … … 1168 1174 * @return string The wrapped text 1169 1175 */ 1170 function rcmail_wrap_ quoted($text, $max = 76)1176 function rcmail_wrap_and_quote($text, $length = 72) 1171 1177 { 1172 1178 // Rebuild the message body with a maximum of $max chars, while keeping quoted message. 1179 $max = min(78, $length + 8); 1173 1180 $lines = preg_split('/\r?\n/', trim($text)); 1174 1181 $out = ''; 1175 1182 1176 1183 foreach ($lines as $line) { 1177 if (strlen($line) > $max) { 1178 if (preg_match('/^([>\s]+)/', $line, $regs)) { 1179 $length = strlen($regs[0]); 1180 $prefix = substr($line, 0, $length); 1181 1182 // Remove '> ' from the line, then wordwrap() the line 1183 $line = rc_wordwrap(substr($line, $length), $max - $length); 1184 1185 // Rebuild the line with '> ' at the beginning of each 'subline' 1186 $newline = ''; 1187 foreach (explode("\n", $line) as $l) { 1188 $newline .= $prefix . $l . "\n"; 1189 } 1190 1191 // Remove the righest newline char 1192 $line = rtrim($newline); 1184 // don't wrap already quoted lines 1185 if ($line[0] == '>') 1186 $line = '>' . rtrim($line); 1187 else if (mb_strlen($line) > $max) { 1188 $newline = ''; 1189 foreach(explode("\n", rc_wordwrap($line, $length - 2)) as $l) { 1190 if (strlen($l)) 1191 $newline .= '> ' . $l . "\n"; 1192 else 1193 $newline .= ">\n"; 1193 1194 } 1194 else {1195 $line = rc_wordwrap($line, $max);1196 }1197 }1195 $line = rtrim($newline); 1196 } 1197 else 1198 $line = '> ' . $line; 1198 1199 1199 1200 // Append the line -
trunk/roundcubemail/program/steps/mail/sendmail.inc
r3642 r3644 6 6 | | 7 7 | This file is part of the RoundCube Webmail client | 8 | Copyright (C) 2005-20 09, RoundCube Dev. - Switzerland |8 | Copyright (C) 2005-2010, RoundCube Dev. - Switzerland | 9 9 | Licensed under the GNU GPL | 10 10 | | … … 441 441 $message_body = rcmail_attach_emoticons($MAIL_MIME); 442 442 } 443 else 444 { 445 $message_body = rc_wordwrap($message_body, $LINE_LENGTH, "\r\n"); 443 else { 446 444 if ($footer) 447 445 $message_body .= "\r\n" . $footer; 446 447 // compose format=flowed content if enabled and not a reply message 448 if (empty($_SESSION['compose']['reply_msgid']) && ($flowed = $RCMAIL->config->get('send_format_flowed', true))) 449 $message_body = rcube_message::format_flowed($message_body, $LINE_LENGTH); 450 else 451 $message_body = rc_wordwrap($message_body, min(79, $LINE_LENGTH + 8), "\r\n"); // +8: be generous with quoted lines 452 448 453 $message_body = wordwrap($message_body, 998, "\r\n", true); 449 454 if (!strlen($message_body)) { … … 504 509 $MAIL_MIME->setParam('head_charset', $message_charset); 505 510 $MAIL_MIME->setParam('html_charset', $message_charset); 506 $MAIL_MIME->setParam('text_charset', $message_charset );511 $MAIL_MIME->setParam('text_charset', $message_charset . ($flowed ? ";\r\n format=flowed" : '')); 507 512 508 513 // encoding subject header with mb_encode provides better results with asian characters
Note: See TracChangeset
for help on using the changeset viewer.
