Changeset 3960 in subversion
- Timestamp:
- Sep 11, 2010 9:21:34 AM (3 years ago)
- Location:
- trunk/roundcubemail
- Files:
-
- 3 edited
-
CHANGELOG (modified) (1 diff)
-
program/include/main.inc (modified) (2 diffs)
-
program/steps/mail/func.inc (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/roundcubemail/CHANGELOG
r3951 r3960 21 21 - Re-added 'Close' button in upload form (#1486930, #1486823) 22 22 - Fix handling of charsets with LATIN-* label 23 - Fix messages background image handling in some cases (#1486990) 23 24 24 25 RELEASE 0.4 -
trunk/roundcubemail/program/include/main.inc
r3952 r3960 846 846 $last_pos = 0; 847 847 $replacements = new rcube_string_replacer; 848 848 849 849 // ignore the whole block if evil styles are detected 850 850 $stripped = preg_replace('/[^a-z\(:]/', '', rcmail_xss_entity_decode($source)); … … 869 869 '/(^\s*<!--)|(-->\s*$)/', 870 870 '/(^\s*|,\s*|\}\s*)([a-z0-9\._#\*][a-z0-9\.\-_]*)/im', 871 "/$container_id\s+body/i",871 '/'.preg_quote($container_id, '/').'\s+body/i', 872 872 ), 873 873 array( 874 874 '', 875 875 "\\1#$container_id \\2", 876 "$container_id div.rcmBody",876 $container_id, 877 877 ), 878 878 $source); 879 879 880 880 // put block contents back in 881 881 $styles = $replacements->resolve($styles); -
trunk/roundcubemail/program/steps/mail/func.inc
r3923 r3960 995 995 $style = array(); 996 996 997 if (!empty($attrs ['color']))998 $style[] = 'background-color: '.$attrs['color'];999 if (!empty($attrs['image']))1000 $style[] = 'background-image: url('.$attrs['image'].')';1001 if (!empty($style))1002 $div_attr['style'] = implode('; ', $style);997 if (!empty($attrs)) { 998 foreach ($attrs as $a_idx => $a_val) 999 $style[] = $a_idx . ': ' . $a_val; 1000 if (!empty($style)) 1001 $div_attr['style'] = implode('; ', $style); 1002 } 1003 1003 1004 1004 $out .= html::div($div_attr, $plugin['prefix'] . $body); … … 1072 1072 */ 1073 1073 function rcmail_html4inline($body, $container_id, $body_id='', &$attributes=null) 1074 {1074 { 1075 1075 $last_style_pos = 0; 1076 1076 $body_lc = strtolower($body); 1077 $cont_id = $container_id.($body_id ? ' div.'.$body_id : ''); 1077 1078 1078 1079 // find STYLE tags 1079 1080 while (($pos = strpos($body_lc, '<style', $last_style_pos)) && ($pos2 = strpos($body_lc, '</style>', $pos))) 1080 {1081 { 1081 1082 $pos = strpos($body_lc, '>', $pos)+1; 1082 1083 1083 1084 // replace all css definitions with #container [def] 1084 $styles = rcmail_mod_css_styles( substr($body, $pos, $pos2-$pos),1085 $container_id.($body_id ? ' div.'.$body_id : ''));1085 $styles = rcmail_mod_css_styles( 1086 substr($body, $pos, $pos2-$pos), $cont_id); 1086 1087 1087 1088 $body = substr($body, 0, $pos) . $styles . substr($body, $pos2); 1088 1089 $body_lc = strtolower($body); 1089 1090 $last_style_pos = $pos2; 1090 }1091 } 1091 1092 1092 1093 // modify HTML links to open a new window if clicked … … 1095 1096 unset($GLOBALS['rcmail_html_container_id']); 1096 1097 1097 $ out= preg_replace(array(1098 $body = preg_replace(array( 1098 1099 // add comments arround html and other tags 1099 1100 '/(<!DOCTYPE[^>]*>)/i', … … 1127 1128 1128 1129 // Handle body attributes that doesn't play nicely with div elements 1129 if (preg_match('/<div class="' . preg_quote($body_id, '/') . '" ([^>]+)/', $ out, $m)) {1130 if (preg_match('/<div class="' . preg_quote($body_id, '/') . '" ([^>]+)/', $body, $m)) { 1130 1131 $attrs = $m[0]; 1131 1132 // Get bgcolor, we'll set it as background-color of the message container 1132 1133 if (preg_match('/bgcolor=["\']*([a-z0-9#]+)["\']*/', $attrs, $mb)) { 1133 $attributes[' color'] = $mb[1];1134 $attributes['background-color'] = $mb[1]; 1134 1135 $attrs = preg_replace('/bgcolor=["\']*([a-z0-9#]+)["\']*/', '', $attrs); 1135 1136 } 1136 1137 // Get background, we'll set it as background-image of the message container 1137 1138 if (preg_match('/background=["\']*([^"\'>\s]+)["\']*/', $attrs, $mb)) { 1138 $attributes[' image'] = $mb[1];1139 $attributes['background-image'] = 'url('.$mb[1].')'; 1139 1140 $attrs = preg_replace('/background=["\']*([^"\'>\s]+)["\']*/', '', $attrs); 1140 1141 } 1141 1142 if (!empty($attributes)) 1142 $out = preg_replace('/<div class="' . preg_quote($body_id, '/') . '" [^>]+/', rtrim($attrs), $out, 1); 1143 $body = preg_replace('/<div class="' . preg_quote($body_id, '/') . '" [^>]+/', rtrim($attrs), $body, 1); 1144 1145 // handle body styles related to background image 1146 if ($attributes['background-image']) { 1147 // get body style 1148 if (preg_match('/#'.preg_quote($cont_id, '/').'\s+\{([^}]+)}/i', $body, $m)) { 1149 // get background related style 1150 if (preg_match_all('/(background-position|background-repeat)\s*:\s*([^;]+);/i', $m[1], $ma, PREG_SET_ORDER)) { 1151 foreach ($ma as $style) 1152 $attributes[$style[1]] = $style[2]; 1153 } 1154 } 1155 } 1143 1156 } 1144 1157 // make sure there's 'rcmBody' div, we need it for proper css modification 1145 1158 // its name is hardcoded in rcmail_message_body() also 1146 1159 else 1147 $ out = '<div class="' . $body_id . '">' . $out. '</div>';1148 1149 return $ out;1150 }1160 $body = '<div class="' . $body_id . '">' . $body . '</div>'; 1161 1162 return $body; 1163 } 1151 1164 1152 1165
Note: See TracChangeset
for help on using the changeset viewer.
