diff options
| author | alec <alec@208e9e7b-5314-0410-a742-e7e81cd9613c> | 2010-12-23 17:08:07 +0000 |
|---|---|---|
| committer | alec <alec@208e9e7b-5314-0410-a742-e7e81cd9613c> | 2010-12-23 17:08:07 +0000 |
| commit | 9cc60b64387d727c340026fbbb7c51b101382208 (patch) | |
| tree | 78678d4333bb686683e57a6185f545c675e8cf5d /roundcubemail/program | |
| parent | 7082e8ad8c32ebd97907e410f80d323bf0a90caf (diff) | |
- Fix duplicated rcmBody div
git-svn-id: https://svn.roundcube.net/trunk@4365 208e9e7b-5314-0410-a742-e7e81cd9613c
Diffstat (limited to 'roundcubemail/program')
| -rw-r--r-- | roundcubemail/program/steps/mail/func.inc | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/roundcubemail/program/steps/mail/func.inc b/roundcubemail/program/steps/mail/func.inc index 750cf6f61..d4e250b03 100644 --- a/roundcubemail/program/steps/mail/func.inc +++ b/roundcubemail/program/steps/mail/func.inc @@ -1143,20 +1143,22 @@ function rcmail_html4inline($body, $container_id, $body_id='', &$attributes=null $attributes = array(); // Handle body attributes that doesn't play nicely with div elements - if (preg_match('/<div class="' . preg_quote($body_id, '/') . '" ([^>]+)/', $body, $m)) { + $regexp = '/<div class="' . preg_quote($body_id, '/') . '"([^>]*)/'; + if (preg_match($regexp, $body, $m)) { $attrs = $m[0]; // Get bgcolor, we'll set it as background-color of the message container - if (preg_match('/bgcolor=["\']*([a-z0-9#]+)["\']*/', $attrs, $mb)) { + if ($m[1] && preg_match('/bgcolor=["\']*([a-z0-9#]+)["\']*/', $attrs, $mb)) { $attributes['background-color'] = $mb[1]; $attrs = preg_replace('/bgcolor=["\']*([a-z0-9#]+)["\']*/', '', $attrs); } // Get background, we'll set it as background-image of the message container - if (preg_match('/background=["\']*([^"\'>\s]+)["\']*/', $attrs, $mb)) { + if ($m[1] && preg_match('/background=["\']*([^"\'>\s]+)["\']*/', $attrs, $mb)) { $attributes['background-image'] = 'url('.$mb[1].')'; $attrs = preg_replace('/background=["\']*([^"\'>\s]+)["\']*/', '', $attrs); } - if (!empty($attributes)) - $body = preg_replace('/<div class="' . preg_quote($body_id, '/') . '" [^>]+/', rtrim($attrs), $body, 1); + if (!empty($attributes)) { + $body = preg_replace($regexp, rtrim($attrs), $body, 1); + } // handle body styles related to background image if ($attributes['background-image']) { @@ -1172,8 +1174,9 @@ function rcmail_html4inline($body, $container_id, $body_id='', &$attributes=null } // make sure there's 'rcmBody' div, we need it for proper css modification // its name is hardcoded in rcmail_message_body() also - else + else { $body = '<div class="' . $body_id . '">' . $body . '</div>'; + } return $body; } |
