lib/kolab_sync_data_email.php

Aleksander Machniak machniak at kolabsys.com
Thu Jan 2 13:49:23 CET 2014


 lib/kolab_sync_data_email.php |   11 +++++++++++
 1 file changed, 11 insertions(+)

New commits:
commit afc041f7d619d0118bb6b9cdd54f02b53ecc3c35
Author: Aleksander Machniak <alec at alec.pl>
Date:   Thu Jan 2 13:48:44 2014 +0100

    Replace charset specification in meta header of HTML content

diff --git a/lib/kolab_sync_data_email.php b/lib/kolab_sync_data_email.php
index 3d7f835..1322f44 100644
--- a/lib/kolab_sync_data_email.php
+++ b/lib/kolab_sync_data_email.php
@@ -1165,6 +1165,17 @@ class kolab_sync_data_email extends kolab_sync_data implements Syncroton_Data_ID
 
         if ($html) {
             if ($part->ctype_secondary == 'html') {
+                // charset was converted to UTF-8 in rcube_storage::get_message_part(),
+                // change/add charset specification in HTML accordingly
+                $meta = '<meta http-equiv="Content-Type" content="text/html; charset='.RCUBE_CHARSET.'" />';
+
+                // remove old meta tag and add the new one, making sure
+                // that it is placed in the head
+                $body = preg_replace('/<meta[^>]+charset=[a-z0-9-_]+[^>]*>/Ui', '', $body);
+                $body = preg_replace('/(<head[^>]*>)/Ui', '\\1'.$meta, $body, -1, $rcount);
+                if (!$rcount) {
+                    $body = '<head>' . $meta . '</head>' . $body;
+                }
             }
             else if ($part->ctype_secondary == 'enriched') {
                 $body = rcube_enriched::to_html($body);




More information about the commits mailing list