summaryrefslogtreecommitdiff
path: root/program
diff options
context:
space:
mode:
authoralecpl <alec@alec.pl>2009-07-31 09:13:11 +0000
committeralecpl <alec@alec.pl>2009-07-31 09:13:11 +0000
commit269fb829ceca9b6db7946c282b22a0fedf60d801 (patch)
tree88d114caf6f489b296853300d2107dae8e00e318 /program
parente54bb72d30cfd88fcef5434b472fb3d9b2cca710 (diff)
- revert r2819 commit removed in last commit
Diffstat (limited to 'program')
-rw-r--r--program/steps/mail/func.inc20
1 files changed, 11 insertions, 9 deletions
diff --git a/program/steps/mail/func.inc b/program/steps/mail/func.inc
index d82c8ef71..dd7b38815 100644
--- a/program/steps/mail/func.inc
+++ b/program/steps/mail/func.inc
@@ -688,16 +688,18 @@ function rcmail_wash_html($html, $p = array(), $cid_replaces)
$html = preg_replace_callback('/(<[\/!]*)([^ >]+)/', 'rcmail_html_tag_callback', $html);
// charset was converted to UTF-8 in rcube_imap::get_message_part(),
- // change charset specification in HTML accordingly
- $charset_pattern = '/(\s+content=[\'"]?\w+\/\w+;\s*charset)=([a-z0-9-_]+)/i';
- if (preg_match($charset_pattern, $html)) {
- $html = preg_replace($charset_pattern, '\\1='.RCMAIL_CHARSET, $html);
+ // -> change charset specification in HTML accordingly
+ $charset_pattern = '(content=[\'"]?\w+\/\w+;\s*charset)=([a-z0-9-_]+)';
+ if (preg_match("/<meta\s+[^>]*$charset_pattern/Ui", $html)) {
+ $html = preg_replace("/\s+$charset_pattern/i", '\\1='.RCMAIL_CHARSET, $html);
}
- // add head for malformed messages, washtml cannot work without that
- if (!preg_match('/<head[^>]*>(.*)<\/head>/Uims', $html))
- $html = '<head></head>'. $html;
- $html = substr_replace($html, '<meta http-equiv="Content-Type" content="text/html; charset='.RCMAIL_CHARSET.'" />', intval(stripos($html, '<head>')+6), 0);
-
+ else {
+ // add meta content-type to malformed messages, washtml cannot work without that
+ if (!preg_match('/<head[^>]*>(.*)<\/head>/Uims', $html))
+ $html = '<head></head>'. $html;
+ $html = substr_replace($html, '<meta http-equiv="Content-Type" content="text/html; charset='.RCMAIL_CHARSET.'" />', intval(stripos($html, '<head>')+6), 0);
+ }
+
// turn relative into absolute urls
$html = rcmail_resolve_base($html);