diff --git a/CHANGELOG b/CHANGELOG index 0d940d7a3..9ad46bd5b 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -32,6 +32,7 @@ CHANGELOG Roundcube Webmail - Fix bug where 'text' attribute on body tag was ignored when displaying HTML message (#7109) - Fix bug where next message wasn't displayed after delete in List mode (#7096) - Fix so number of contacts in a group is not limited to 200 when redirecting to mail composer from Contacts (#6972) +- Fix malformed characters in HTML message with charset meta tag not in head (#7116) RELEASE 1.4.1 ------------- diff --git a/program/steps/mail/func.inc b/program/steps/mail/func.inc index ae396cff1..ed75b2d8a 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 = ''; - // remove old meta tag and add the new one, making sure - // that it is placed in the head (#1488093) - $html = preg_replace('/]+charset=[a-z0-9_"-]+[^>]*>/Ui', $meta, $html, -1, $rcount); - if (!$rcount) { - $html = preg_replace('/(]*>)/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('/]+charset=[a-z0-9_"-]+[^>]*>/Ui', '', $html); + $html = preg_replace('/(]*>)/Ui', '\\1'.$meta, $html, -1, $rcount); + if (!$rcount) { // Note: HTML without tag may still be a valid input (#6713) if (($pos = stripos($html, 'assertTrue(strpos($washed, "$meta") === 0, "Meta tag insertion (5)"); + + $body = 'Test1
Test2'; + $washed = rcmail_wash_html($body, $args); + $this->assertTrue(strpos($washed, "$meta") === 0, "Meta tag insertion (6)"); + $this->assertTrue(strpos($washed, "Test2") > 0, "Meta tag insertion (7)"); } /**