Changeset 5586 in subversion
- Timestamp:
- Dec 9, 2011 4:13:54 PM (18 months ago)
- Location:
- trunk/roundcubemail/program
- Files:
-
- 3 edited
-
include/main.inc (modified) (3 diffs)
-
lib/washtml.php (modified) (2 diffs)
-
steps/mail/func.inc (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/roundcubemail/program/include/main.inc
r5562 r5586 884 884 * @return string Modified CSS source 885 885 */ 886 function rcmail_mod_css_styles($source, $container_id )886 function rcmail_mod_css_styles($source, $container_id, $allow_remote=false) 887 887 { 888 888 $last_pos = 0; … … 890 890 891 891 // ignore the whole block if evil styles are detected 892 $stripped = preg_replace('/[^a-z\(:;]/', '', rcmail_xss_entity_decode($source)); 893 if (preg_match('/expression|behavior|url\(|import[^a]/', $stripped)) 892 $source = rcmail_xss_entity_decode($source); 893 $stripped = preg_replace('/[^a-z\(:;]/i', '', $source); 894 $evilexpr = 'expression|behavior' . (!$allow_remote ? '|url\(|import[^a]' : ''); 895 if (preg_match("/$evilexpr/i", $stripped) // don't accept No-Gos 896 || (strpos($stripped, 'url(') && !preg_match('!url\s*\([ "\'](https?:)//[a-z0-9/._+-]+["\' ]\)!Ui', $source))) // only allow clean urls 894 897 return '/* evil! */'; 895 896 // remove css comments (sometimes used for some ugly hacks)897 $source = preg_replace('!/\*(.+)\*/!Ums', '', $source);898 898 899 899 // cut out all contents between { and } … … 938 938 $out = html_entity_decode(html_entity_decode($content)); 939 939 $out = preg_replace_callback('/\\\([0-9a-f]{4})/i', 'rcmail_xss_entity_decode_callback', $out); 940 $out = preg_replace('#/\*.*\*/#Um ', '', $out);940 $out = preg_replace('#/\*.*\*/#Ums', '', $out); 941 941 return $out; 942 942 } -
trunk/roundcubemail/program/lib/washtml.php
r5511 r5586 244 244 $tagName = strtolower($node->tagName); 245 245 if ($callback = $this->handlers[$tagName]) { 246 $dump .= call_user_func($callback, $tagName, $this->wash_attribs($node), $this->dumpHtml($node) );246 $dump .= call_user_func($callback, $tagName, $this->wash_attribs($node), $this->dumpHtml($node), $this); 247 247 } 248 248 else if (isset($this->_html_elements[$tagName])) { … … 302 302 } 303 303 304 /** 305 * Getter for config parameters 306 */ 307 public function get_config($prop) 308 { 309 return $this->config[$prop]; 310 } 311 304 312 } 305 313 -
trunk/roundcubemail/program/steps/mail/func.inc
r5563 r5586 823 823 * Callback function for washtml cleaning class 824 824 */ 825 function rcmail_washtml_callback($tagname, $attrib, $content )825 function rcmail_washtml_callback($tagname, $attrib, $content, $washtml) 826 826 { 827 827 switch ($tagname) { … … 835 835 836 836 // now check for evil strings like expression, behavior or url() 837 if (!preg_match('/expression|behavior|url\(|import[^a]/', $stripped)) { 838 $out = html::tag('style', array('type' => 'text/css'), $content); 837 if (!preg_match('/expression|behavior/i', $stripped)) { 838 if (!$washtml->get_config('allow_remote') && preg_match('/url\(|import[^a]/i', $stripped)) 839 $washtml->extlinks = true; 840 else 841 $out = html::tag('style', array('type' => 'text/css'), $content); 839 842 break; 840 843 } … … 1022 1025 1023 1026 if ($part->ctype_secondary == 'html') { 1024 $body = rcmail_html4inline($body, $attrib['id'], 'rcmBody', $attrs );1027 $body = rcmail_html4inline($body, $attrib['id'], 'rcmBody', $attrs, $safe_mode); 1025 1028 $div_attr = array('class' => 'message-htmlpart'); 1026 1029 $style = array(); … … 1105 1108 * modify a HTML message that it can be displayed inside a HTML page 1106 1109 */ 1107 function rcmail_html4inline($body, $container_id, $body_id='', &$attributes=null )1110 function rcmail_html4inline($body, $container_id, $body_id='', &$attributes=null, $allow_remote=false) 1108 1111 { 1109 1112 $last_style_pos = 0; … … 1117 1120 // replace all css definitions with #container [def] 1118 1121 $styles = rcmail_mod_css_styles( 1119 substr($body, $pos, $pos2-$pos), $cont_id );1122 substr($body, $pos, $pos2-$pos), $cont_id, $allow_remote); 1120 1123 1121 1124 $body = substr_replace($body, $styles, $pos, $pos2-$pos);
Note: See TracChangeset
for help on using the changeset viewer.
