Changeset 2802 in subversion
- Timestamp:
- Jul 28, 2009 4:41:50 AM (4 years ago)
- Location:
- trunk/roundcubemail
- Files:
-
- 3 edited
-
CHANGELOG (modified) (1 diff)
-
program/lib/washtml.php (modified) (3 diffs)
-
program/steps/mail/func.inc (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/roundcubemail/CHANGELOG
r2779 r2802 2 2 =========================== 3 3 4 - Fix displaying of HTML messages with unknown/malformed tags (#1486003) 5 6 RELEASE 0.3-RC1 7 --------------- 4 8 - Fix import of vCard entries with params (#1485453) 5 9 - Fix HTML messages output with empty block elements (#1485974) -
trunk/roundcubemail/program/lib/washtml.php
r2759 r2802 70 70 * - Dont alter data on a GET: '<img src="http://yourhost/mail?action=delete&uid=3267" />' 71 71 * - ... 72 * 73 * Roundcube Changes: 74 * - added $block_elements 75 * - changed $ignore_elements behaviour 72 76 */ 73 77 … … 77 81 static $html_elements = array('a', 'abbr', 'acronym', 'address', 'area', 'b', 'basefont', 'bdo', 'big', 'blockquote', 'br', 'caption', 'center', 'cite', 'code', 'col', 'colgroup', 'dd', 'del', 'dfn', 'dir', 'div', 'dl', 'dt', 'em', 'fieldset', 'font', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'hr', 'i', 'ins', 'label', 'legend', 'li', 'map', 'menu', 'nobr', 'ol', 'p', 'pre', 'q', 's', 'samp', 'small', 'span', 'strike', 'strong', 'sub', 'sup', 'table', 'tbody', 'td', 'tfoot', 'th', 'thead', 'tr', 'tt', 'u', 'ul', 'var', 'wbr', 'img'); 78 82 79 /* Ignore these HTML tags but processtheir content */80 static $ignore_elements = array(' html', 'head', 'body');83 /* Ignore these HTML tags and their content */ 84 static $ignore_elements = array('script', 'applet', 'embed', 'object', 'style'); 81 85 82 86 /* Allowed HTML attributes */ … … 210 214 $content = $this->dumpHtml($node); 211 215 $dump .= '<' . $tagName . $this->wash_attribs($node) . 212 // ($content?">$content</$tagName>":' />');213 // Roundcube Trac: #1485974214 216 ($content || isset($this->_block_elements[$tagName]) ? ">$content</$tagName>" : ' />'); 215 217 } else if(isset($this->_ignore_elements[$tagName])) { 218 $dump .= '<!-- ' . htmlspecialchars($tagName, ENT_QUOTES) . ' not allowed -->'; 219 } else { 216 220 $dump .= '<!-- ' . htmlspecialchars($tagName, ENT_QUOTES) . ' ignored -->'; 217 $dump .= $this->dumpHtml($node); //Just ignored 218 } else 219 $dump .= '<!-- ' . htmlspecialchars($tagName, ENT_QUOTES) . ' not allowed -->'; 221 $dump .= $this->dumpHtml($node); // ignore tags not its content 222 } 220 223 break; 221 224 case XML_CDATA_SECTION_NODE: -
trunk/roundcubemail/program/steps/mail/func.inc
r2776 r2802 429 429 $action = $mbox==$CONFIG['drafts_mbox'] ? 'compose' : 'show'; 430 430 $uid_param = $mbox==$CONFIG['drafts_mbox'] ? '_draft_uid' : '_uid'; 431 $cont = abbreviate_string(trim($IMAP->decode_header($header->$col)), 160); 431 $cont = trim($IMAP->decode_header($header->$col)); 432 if ($browser->ie) 433 $cont = rc_utf8_clean($cont); 434 $cont = abbreviate_string($cont, 160); 432 435 if (!$cont) $cont = rcube_label('nosubject'); 433 436 $cont = $browser->ie ? Q($cont) : sprintf('<a href="%s" onclick="return rcube_event.cancel(event)">%s</a>', Q(rcmail_url($action, array($uid_param=>$header->uid, '_mbox'=>$mbox))), Q($cont)); … … 669 672 670 673 $p += array('safe' => false, 'inline_html' => true); 671 674 672 675 // special replacements (not properly handled by washtml class) 673 676 $html_search = array( 674 677 '/(<\/nobr>)(\s+)(<nobr>)/i', // space(s) between <NOBR> 675 '/(<[\/]*st1:[^>]+>)/i', // Microsoft's Smart Tags <ST1>676 '/<\/?rte_text>/i', // Rich Text Editor tags (#1485647)677 '/<\/?broadcast[^>]*>/i', // invoices from the Apple Store contains <broadcast> tags (#1485962)678 678 '/<title>.*<\/title>/i', // PHP bug #32547 workaround: remove title tag 679 '/<html[^>]*>/im', // malformed html: remove html tags (#1485139)680 '/<\/html>/i', // malformed html: remove html tags (#1485139)681 679 '/^(\0\0\xFE\xFF|\xFF\xFE\0\0|\xFE\xFF|\xFF\xFE|\xEF\xBB\xBF)/', // byte-order mark (only outlook?) 682 680 ); … … 685 683 '', 686 684 '', 687 '',688 '',689 '',690 '',691 '',692 685 ); 693 686 $html = preg_replace($html_search, $html_replace, $html); 687 688 // fix (unknown/malformed) HTML tags before "wash" 689 $html = preg_replace_callback('/(<[\/!]*)([^ >]+)/', 'rcmail_html_tag_callback', $html); 694 690 695 691 // charset was converted to UTF-8 in rcube_imap::get_message_part() -> change charset specification in HTML accordingly … … 697 693 if (preg_match($charset_pattern, $html)) { 698 694 $html = preg_replace($charset_pattern, '\\1='.RCMAIL_CHARSET, $html); 699 } 700 else { 695 } else { 701 696 // add head for malformed messages, washtml cannot work without that 702 697 if (!preg_match('/<head[^>]*>(.*)<\/head>/Uims', $html)) … … 729 724 $washer->add_callback('form', 'rcmail_washtml_callback'); 730 725 731 if ($p['safe']) { // allow CSS styles, will be sanitized by rcmail_washtml_callback() 732 $washer->add_callback('style', 'rcmail_washtml_callback'); 733 } 726 // allow CSS styles, will be sanitized by rcmail_washtml_callback() 727 $washer->add_callback('style', 'rcmail_washtml_callback'); 734 728 735 729 $html = $washer->wash($html); … … 884 878 885 879 /** 880 * Callback function for HTML tags fixing 881 */ 882 function rcmail_html_tag_callback($matches) 883 { 884 $tagname = $matches[2]; 885 886 $tagname = preg_replace(array( 887 '/:.*$/', // Microsoft's Smart Tags <st1:xxxx> 888 '/[^a-z0-9_-]/i', // forbidden characters 889 ), '', $tagname); 890 891 return $matches[1].$tagname; 892 } 893 894 895 /** 886 896 * return table with message headers 887 897 */
Note: See TracChangeset
for help on using the changeset viewer.
