Changeset 5591 in subversion
- Timestamp:
- Dec 10, 2011 9:16:31 AM (18 months ago)
- Location:
- branches/release-0.7
- Files:
-
- 4 edited
-
CHANGELOG (modified) (1 diff)
-
program/include/main.inc (modified) (3 diffs)
-
program/lib/washtml.php (modified) (3 diffs)
-
program/steps/mail/func.inc (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/release-0.7/CHANGELOG
r5582 r5591 4 4 RELEASE 0.7 5 5 ----------- 6 - Make Roundcube render the Email Standards Project Acid Test correctly 6 7 - Replace prompt() with jQuery UI dialog (#1485135) 7 8 - Fix navigation in messages search results -
branches/release-0.7/program/include/main.inc
r5499 r5591 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|javascript:|import[^a]' . (!$allow_remote ? '|url\(' : ''); 895 if (preg_match("/$evilexpr/i", $stripped)) 894 896 return '/* evil! */'; 895 897 896 // remove css comments (sometimes used for some ugly hacks)897 $source = preg_replace('!/\*(.+)\*/!Ums', '', $source);898 899 898 // cut out all contents between { and } 900 while (($pos = strpos($source, '{', $last_pos)) && ($pos2 = strpos($source, '}', $pos))) 901 { 902 $key = $replacements->add(substr($source, $pos+1, $pos2-($pos+1))); 899 while (($pos = strpos($source, '{', $last_pos)) && ($pos2 = strpos($source, '}', $pos))) { 900 $styles = substr($source, $pos+1, $pos2-($pos+1)); 901 902 // check every line of a style block... 903 if ($allow_remote) { 904 $a_styles = preg_split('/;[\r\n]*/', $styles, -1, PREG_SPLIT_NO_EMPTY); 905 foreach ($a_styles as $line) { 906 $stripped = preg_replace('/[^a-z\(:;]/i', '', $line); 907 // ... and only allow strict url() values 908 if (stripos($stripped, 'url(') && !preg_match('!url\s*\([ "\'](https?:)//[a-z0-9/._+-]+["\' ]\)!Uims', $line)) { 909 $a_styles = array('/* evil! */'); 910 break; 911 } 912 } 913 $styles = join(";\n", $a_styles); 914 } 915 916 $key = $replacements->add($styles); 903 917 $source = substr($source, 0, $pos+1) . $replacements->get_replacement($key) . substr($source, $pos2, strlen($source)-$pos2); 904 918 $last_pos = $pos+2; … … 938 952 $out = html_entity_decode(html_entity_decode($content)); 939 953 $out = preg_replace_callback('/\\\([0-9a-f]{4})/i', 'rcmail_xss_entity_decode_callback', $out); 940 $out = preg_replace('#/\*.*\*/#Um ', '', $out);954 $out = preg_replace('#/\*.*\*/#Ums', '', $out); 941 955 return $out; 942 956 } -
branches/release-0.7/program/lib/washtml.php
r5514 r5591 169 169 $value .= ' url('.htmlspecialchars($src, ENT_QUOTES) . ')'; 170 170 } 171 else if (preg_match(' /^(http|https|ftp):.*$/i', $match[2], $url)) {171 else if (preg_match('!^(https?:)?//[a-z0-9/._+-]+$!i', $match[2], $url)) { 172 172 if ($this->config['allow_remote']) 173 173 $value .= ' url('.htmlspecialchars($url[0], ENT_QUOTES).')'; … … 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 -
branches/release-0.7/program/steps/mail/func.inc
r5527 r5591 822 822 * Callback function for washtml cleaning class 823 823 */ 824 function rcmail_washtml_callback($tagname, $attrib, $content )824 function rcmail_washtml_callback($tagname, $attrib, $content, $washtml) 825 825 { 826 826 switch ($tagname) { … … 834 834 835 835 // now check for evil strings like expression, behavior or url() 836 if (!preg_match('/expression|behavior|url\(|import[^a]/', $stripped)) { 837 $out = html::tag('style', array('type' => 'text/css'), $content); 836 if (!preg_match('/expression|behavior|javascript:|import[^a]/i', $stripped)) { 837 if (!$washtml->get_config('allow_remote') && stripos($stripped, 'url(')) 838 $washtml->extlinks = true; 839 else 840 $out = html::tag('style', array('type' => 'text/css'), $content); 838 841 break; 839 842 } … … 1015 1018 1016 1019 if ($part->ctype_secondary == 'html') { 1017 $body = rcmail_html4inline($body, $attrib['id'], 'rcmBody', $attrs );1020 $body = rcmail_html4inline($body, $attrib['id'], 'rcmBody', $attrs, $safe_mode); 1018 1021 $div_attr = array('class' => 'message-htmlpart'); 1019 1022 $style = array(); … … 1089 1092 * modify a HTML message that it can be displayed inside a HTML page 1090 1093 */ 1091 function rcmail_html4inline($body, $container_id, $body_id='', &$attributes=null )1094 function rcmail_html4inline($body, $container_id, $body_id='', &$attributes=null, $allow_remote=false) 1092 1095 { 1093 1096 $last_style_pos = 0; … … 1102 1105 // replace all css definitions with #container [def] 1103 1106 $styles = rcmail_mod_css_styles( 1104 substr($body, $pos, $pos2-$pos), $cont_id );1107 substr($body, $pos, $pos2-$pos), $cont_id, $allow_remote); 1105 1108 1106 1109 $body = substr($body, 0, $pos) . $styles . substr($body, $pos2); … … 1280 1283 'onclick' => sprintf("return %s.command('add-contact','%s',this)", JS_OBJECT_NAME, urlencode($string)), 1281 1284 'title' => rcube_label('addtoaddressbook'), 1285 'class' => 'rcmaddcontact', 1282 1286 ), 1283 1287 html::img(array(
Note: See TracChangeset
for help on using the changeset viewer.
