diff options
author | Aleksander Machniak <alec@alec.pl> | 2019-12-16 17:13:37 +0300 |
---|---|---|
committer | Aleksander Machniak <alec@alec.pl> | 2019-12-16 17:17:28 +0300 |
commit | 37cfa0a43b542add71b7d8ae9cfcae345448835c (patch) | |
tree | a49973989e0067dd66e83fdb7ed73bbb524b2e2b /program | |
parent | 5f30dc68a3b67eedb57a5f0115b4bad783cb3347 (diff) |
Fix malformed characters in HTML message with charset meta tag not in head (#7116)
Diffstat (limited to 'program')
-rw-r--r-- | program/steps/mail/func.inc | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/program/steps/mail/func.inc b/program/steps/mail/func.inc index ae396cff1..094e877dc 100644 --- a/program/steps/mail/func.inc +++ b/program/steps/mail/func.inc @@ -839,12 +839,10 @@ function rcmail_wash_html($html, $p, $cid_replaces = array()) // washtml's DOMDocument methods cannot work without that $meta = '<meta charset="'.RCUBE_CHARSET.'" />'; - // remove old meta tag and add the new one, making sure - // that it is placed in the head (#1488093) - $html = preg_replace('/<meta[^>]+charset=[a-z0-9_"-]+[^>]*>/Ui', $meta, $html, -1, $rcount); - if (!$rcount) { - $html = preg_replace('/(<head[^>]*>)/Ui', '\\1'.$meta, $html, -1, $rcount); - } + // remove old meta tag and add the new one, making sure that it is placed in the head (#3510, #7116) + $html = preg_replace('/<meta[^>]+charset=[a-z0-9_"-]+[^>]*>/Ui', '', $html, -1); + $html = preg_replace('/(<head[^>]*>)/Ui', '\\1'.$meta, $html, -1, $rcount); + if (!$rcount) { // Note: HTML without <html> tag may still be a valid input (#6713) if (($pos = stripos($html, '<html')) === false) { |