summaryrefslogtreecommitdiff
path: root/program/steps/mail/func.inc
diff options
context:
space:
mode:
authorthomascube <thomas@roundcube.net>2010-05-20 21:28:30 +0000
committerthomascube <thomas@roundcube.net>2010-05-20 21:28:30 +0000
commit6b6f2e83de0e5b48ba48583206bd456508554540 (patch)
tree4d687f9dbd86fb24a1c86703340c19aa7927fc28 /program/steps/mail/func.inc
parente93c72d9a378903502fa51452d6db3fffc3a9b28 (diff)
Display and send messages with format=flowed (#1484370), fixes word wrapping issues (#1486543)
Diffstat (limited to 'program/steps/mail/func.inc')
-rw-r--r--program/steps/mail/func.inc43
1 files changed, 22 insertions, 21 deletions
diff --git a/program/steps/mail/func.inc b/program/steps/mail/func.inc
index 951e777b1..fcb0229df 100644
--- a/program/steps/mail/func.inc
+++ b/program/steps/mail/func.inc
@@ -933,6 +933,10 @@ function rcmail_message_body($attrib)
if (!isset($part->body))
$part->body = $MESSAGE->get_part_content($part->mime_id);
+ // re-format format=flowed content
+ if ($part->ctype_secondary == "plain" && $part->ctype_parameters['format'] == "flowed")
+ $part->body = rcube_message::unfold_flowed($part->body);
+
$body = rcmail_print_body($part, array('safe' => $safe_mode, 'plain' => !$CONFIG['prefer_html']));
if ($part->ctype_secondary == 'html')
@@ -1161,40 +1165,37 @@ function rcmail_address_string($input, $max=null, $linked=false, $addicon=null)
/**
* Wrap text to a given number of characters per line
- * but respect the mail quotation of replies messages (>)
+ * but respect the mail quotation of replies messages (>).
+ * Finally add another quotation level by prpending the lines
+ * with >
*
* @param string Text to wrap
* @param int The line width
* @return string The wrapped text
*/
-function rcmail_wrap_quoted($text, $max = 76)
+function rcmail_wrap_and_quote($text, $length = 72)
{
// Rebuild the message body with a maximum of $max chars, while keeping quoted message.
+ $max = min(78, $length + 8);
$lines = preg_split('/\r?\n/', trim($text));
$out = '';
foreach ($lines as $line) {
- if (strlen($line) > $max) {
- if (preg_match('/^([>\s]+)/', $line, $regs)) {
- $length = strlen($regs[0]);
- $prefix = substr($line, 0, $length);
-
- // Remove '> ' from the line, then wordwrap() the line
- $line = rc_wordwrap(substr($line, $length), $max - $length);
-
- // Rebuild the line with '> ' at the beginning of each 'subline'
- $newline = '';
- foreach (explode("\n", $line) as $l) {
- $newline .= $prefix . $l . "\n";
- }
-
- // Remove the righest newline char
- $line = rtrim($newline);
- }
- else {
- $line = rc_wordwrap($line, $max);
+ // don't wrap already quoted lines
+ if ($line[0] == '>')
+ $line = '>' . rtrim($line);
+ else if (mb_strlen($line) > $max) {
+ $newline = '';
+ foreach(explode("\n", rc_wordwrap($line, $length - 2)) as $l) {
+ if (strlen($l))
+ $newline .= '> ' . $l . "\n";
+ else
+ $newline .= ">\n";
}
+ $line = rtrim($newline);
}
+ else
+ $line = '> ' . $line;
// Append the line
$out .= $line . "\n";