summaryrefslogtreecommitdiff
path: root/roundcubemail/program/steps/mail
diff options
context:
space:
mode:
authorthomasb <thomasb@208e9e7b-5314-0410-a742-e7e81cd9613c>2009-07-31 08:14:37 +0000
committerthomasb <thomasb@208e9e7b-5314-0410-a742-e7e81cd9613c>2009-07-31 08:14:37 +0000
commit00bac278f06e30bfb433205274efdb47d9123e0b (patch)
treede475e1cfaf6cd8a6f7314de0b185dc2b75bc6cc /roundcubemail/program/steps/mail
parentdc1d443a52d8cb955922bddbe0c82ab0b3ab27cb (diff)
Prevent from having two meta tags in html code
git-svn-id: https://svn.roundcube.net/trunk@2819 208e9e7b-5314-0410-a742-e7e81cd9613c
Diffstat (limited to 'roundcubemail/program/steps/mail')
-rw-r--r--roundcubemail/program/steps/mail/func.inc20
1 files changed, 11 insertions, 9 deletions
diff --git a/roundcubemail/program/steps/mail/func.inc b/roundcubemail/program/steps/mail/func.inc
index 2a301ae17..21f0fede7 100644
--- a/roundcubemail/program/steps/mail/func.inc
+++ b/roundcubemail/program/steps/mail/func.inc
@@ -686,16 +686,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);