From 10c92bef09262b7d46e6c87893715bb5a2e5e4a1 Mon Sep 17 00:00:00 2001 From: thomascube Date: Wed, 30 Aug 2006 19:55:55 +0000 Subject: New indentation for quoted message text; HTML validity --- program/steps/mail/func.inc | 41 +++++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 18 deletions(-) (limited to 'program/steps/mail') diff --git a/program/steps/mail/func.inc b/program/steps/mail/func.inc index 8f4f5894c..bae14a299 100644 --- a/program/steps/mail/func.inc +++ b/program/steps/mail/func.inc @@ -214,7 +214,7 @@ function rcmail_render_folder_tree_html(&$arrFolders, &$special, &$mbox_name, $m else if ($folder['id']==$CONFIG['junk_mbox']) $class_name = 'junk'; - $js_name = rep_specialchars_output($folder['id'], 'js'); + $js_name = htmlspecialchars(rep_specialchars_output($folder['id'], 'js')); $out .= sprintf('
  • %s%s'."\n", - $folder['id'], + htmlspecialchars($folder['id']), str_repeat(' ', $nestLevel*4), rep_specialchars_output($foldername, 'html', 'all')); @@ -729,39 +729,44 @@ function rcmail_print_body($part, $safe=FALSE, $plain=FALSE) $convert_patterns[] = '/([a-z0-9][a-z0-9\-\.\+\_]*@[a-z0-9]([a-z0-9\-][.]?)*[a-z0-9]\\.[a-z]{2,5})/ie'; $convert_replaces[] = "rcmail_str_replacement('\\1', \$replace_strings)"; + + if ($part->ctype_parameters['format'] != 'flowed') + $body = wordwrap(trim($body), 80); - $body = wordwrap(trim($body), 80); $body = preg_replace($convert_patterns, $convert_replaces, $body); // split body into single lines $a_lines = preg_split('/\r?\n/', $body); + $quote_level = 0; // colorize quoted parts for($n=0; $n+\s*)/', $line, $regs)) + { + $q = strlen(preg_replace('/\s/', '', $regs[1])); + $line = substr($line, strlen($regs[1])); - if ($line{2}=='>') - $color = 'red'; - else if ($line{1}=='>') - $color = 'green'; - else if ($line{0}=='>') - $color = 'blue'; - else - $color = FALSE; + if ($q > $quote_level) + $quotation = str_repeat('
    ', $q - $quote_level); + else if ($q < $quote_level) + $quotation = str_repeat("
    ", $quote_level - $q); + } + else if ($quote_level > 0) + $quotation = str_repeat("", $quote_level); - $line = rep_specialchars_output($line, 'html', 'replace', FALSE); - - if ($color) - $a_lines[$n] = sprintf('%s', $color, $line); - else - $a_lines[$n] = $line; + $quote_level = $q; + $a_lines[$n] = $quotation . rep_specialchars_output($line, 'html', 'replace', FALSE); } // insert the links for urls and mailtos $body = preg_replace("/##string_replacement\{([0-9]+)\}##/e", "\$replace_strings[\\1]", join("\n", $a_lines)); - return "
    \n".$body."\n
    "; + return "
    \n".$body."\n
    "; } } -- cgit v1.2.3