Changeset 3034 in subversion
- Timestamp:
- Oct 12, 2009 6:37:49 AM (4 years ago)
- Location:
- trunk/roundcubemail
- Files:
-
- 3 edited
-
CHANGELOG (modified) (1 diff)
-
program/include/rcube_imap.php (modified) (1 diff)
-
program/steps/mail/func.inc (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/roundcubemail/CHANGELOG
r3033 r3034 2 2 =========================== 3 3 4 - Partially fixed "empty body" issue by showing raw body of malformed message (#1486166) 4 5 - Fix importing/sending to email address with whitespace (#1486214) 5 6 - Added XIMSS (CommuniGate) driver for Password plugin -
trunk/roundcubemail/program/include/rcube_imap.php
r3027 r3034 1227 1227 $this->struct_charset = $this->_structure_charset($structure); 1228 1228 1229 /* 1230 @TODO: here we can recognize malformed BODYSTRUCTURE and parse 1231 the message in other way to create our own message structure. 1232 Example of structure for malformed MIME message: 1233 ("text" "plain" ("charset" "us-ascii") NIL NIL "7bit" 2154 70 NIL NIL NIL) 1234 1235 if ($headers->ctype != 'text/plain' 1236 && !is_array($structure[0]) && $structure[0] == 'text' 1237 && !is_array($structure[1]) && $structure[1] == 'plain') 1238 { } 1239 */ 1229 // Here we can recognize malformed BODYSTRUCTURE and 1230 // 1. [@TODO] parse the message in other way to create our own message structure 1231 // 2. or just show the raw message body. 1232 // Example of structure for malformed MIME message: 1233 // ("text" "plain" ("charset" "us-ascii") NIL NIL "7bit" 2154 70 NIL NIL NIL) 1234 if ($headers->ctype && $headers->ctype != 'text/plain' 1235 && $structure[0] == 'text' && $structure[1] == 'plain') { 1236 return false; 1237 } 1240 1238 1241 1239 $struct = &$this->_structure_part($structure); -
trunk/roundcubemail/program/steps/mail/func.inc
r3005 r3034 786 786 787 787 // plaintext postprocessing 788 if ($part->ctype_secondary == 'plain') { 789 // make links and email-addresses clickable 790 $replacements = new rcube_string_replacer; 791 792 // search for patterns like links and e-mail addresses 793 $body = preg_replace_callback($replacements->link_pattern, array($replacements, 'link_callback'), $body); 794 $body = preg_replace_callback($replacements->mailto_pattern, array($replacements, 'mailto_callback'), $body); 795 796 // split body into single lines 797 $a_lines = preg_split('/\r?\n/', $body); 798 $q_lines = array(); 799 $quote_level = 0; 800 801 // find/mark quoted lines... 802 for ($n=0, $cnt=count($a_lines); $n < $cnt; $n++) { 803 $q = 0; 804 805 if ($a_lines[$n][0] == '>' && preg_match('/^(>+\s*)+/', $a_lines[$n], $regs)) { 806 $q = strlen(preg_replace('/\s/', '', $regs[0])); 807 $a_lines[$n] = substr($a_lines[$n], strlen($regs[0])); 808 809 if ($q > $quote_level) 810 $q_lines[$n]['quote'] = $q - $quote_level; 811 else if ($q < $quote_level) 812 $q_lines[$n]['endquote'] = $quote_level - $q; 813 } 814 else if ($quote_level > 0) 815 $q_lines[$n]['endquote'] = $quote_level; 816 817 $quote_level = $q; 818 } 819 820 // quote plain text 821 $body = Q(join("\n", $a_lines), 'replace', false); 822 823 // colorize signature 824 if (($sp = strrpos($body, '-- ')) !== false) 825 if (($sp == 0 || $body[$sp-1] == "\n") && $body[$sp+3] == "\n") { 826 $body = substr($body, 0, max(0, $sp)) 827 .'<span class="sig">'.substr($body, $sp).'</span>'; 828 } 829 830 // colorize quoted lines 831 $a_lines = preg_split('/\n/', $body); 832 foreach ($q_lines as $i => $q) 833 if ($q['quote']) 834 $a_lines[$i] = str_repeat('<blockquote>', $q['quote']) . $a_lines[$i]; 835 else if ($q['endquote']) 836 $a_lines[$i] = str_repeat('</blockquote>', $q['endquote']) . $a_lines[$i]; 837 838 // insert the links for urls and mailtos 839 $body = $replacements->resolve(join("\n", $a_lines)); 840 } 788 if ($part->ctype_secondary == 'plain') 789 $body = rcmail_plain_body($body); 841 790 842 791 // allow post-processing of the message body … … 844 793 845 794 return $data['type'] == 'html' ? $data['body'] : html::tag('pre', array(), $data['body']); 795 } 796 797 /** 798 * Handle links and citation marks in plain text message 799 * 800 * @param string Plain text string 801 * @return string Formatted HTML string 802 */ 803 function rcmail_plain_body($body) 804 { 805 // make links and email-addresses clickable 806 $replacements = new rcube_string_replacer; 807 808 // search for patterns like links and e-mail addresses 809 $body = preg_replace_callback($replacements->link_pattern, array($replacements, 'link_callback'), $body); 810 $body = preg_replace_callback($replacements->mailto_pattern, array($replacements, 'mailto_callback'), $body); 811 812 // split body into single lines 813 $a_lines = preg_split('/\r?\n/', $body); 814 $q_lines = array(); 815 $quote_level = 0; 816 817 // find/mark quoted lines... 818 for ($n=0, $cnt=count($a_lines); $n < $cnt; $n++) { 819 $q = 0; 820 821 if ($a_lines[$n][0] == '>' && preg_match('/^(>+\s*)+/', $a_lines[$n], $regs)) { 822 $q = strlen(preg_replace('/\s/', '', $regs[0])); 823 $a_lines[$n] = substr($a_lines[$n], strlen($regs[0])); 824 825 if ($q > $quote_level) 826 $q_lines[$n]['quote'] = $q - $quote_level; 827 else if ($q < $quote_level) 828 $q_lines[$n]['endquote'] = $quote_level - $q; 829 } 830 else if ($quote_level > 0) 831 $q_lines[$n]['endquote'] = $quote_level; 832 833 $quote_level = $q; 834 } 835 836 // quote plain text 837 $body = Q(join("\n", $a_lines), 'replace', false); 838 839 // colorize signature 840 if (($sp = strrpos($body, '-- ')) !== false) 841 if (($sp == 0 || $body[$sp-1] == "\n") && $body[$sp+3] == "\n") { 842 $body = substr($body, 0, max(0, $sp)) 843 .'<span class="sig">'.substr($body, $sp).'</span>'; 844 } 845 846 // colorize quoted lines 847 $a_lines = preg_split('/\n/', $body); 848 foreach ($q_lines as $i => $q) 849 if ($q['quote']) 850 $a_lines[$i] = str_repeat('<blockquote>', $q['quote']) . $a_lines[$i]; 851 else if ($q['endquote']) 852 $a_lines[$i] = str_repeat('</blockquote>', $q['endquote']) . $a_lines[$i]; 853 854 // insert the links for urls and mailtos 855 $body = $replacements->resolve(join("\n", $a_lines)); 856 857 return $body; 846 858 } 847 859 … … 1028 1040 } 1029 1041 else 1030 $out .= html::div('message-part', html::tag('pre', array(), Q($MESSAGE->body))); 1042 $out .= html::div('message-part', html::tag('pre', array(), 1043 rcmail_plain_body(Q($MESSAGE->body, 'strict', false)))); 1031 1044 1032 1045 $ctype_primary = strtolower($MESSAGE->structure->ctype_primary);
Note: See TracChangeset
for help on using the changeset viewer.
