[Tickets #9187] compose html2text charset

bugs at horde.org bugs at horde.org
Thu Aug 19 09:49:12 UTC 2010


DO NOT REPLY TO THIS MESSAGE. THIS EMAIL ADDRESS IS NOT MONITORED.

Ticket URL: http://bugs.horde.org/ticket/9187
------------------------------------------------------------------------------
  Ticket             | 9187
  Created By         | rsalmon at mbpgroup.com
  Summary            | compose html2text charset
  Queue              | IMP
  Version            | Git master
  Type               | Bug
  State              | Unconfirmed
  Priority           | 1. Low
  Milestone          |
  Patch              | 1
  Owners             |
+New Attachment     | email.eml
------------------------------------------------------------------------------


rsalmon at mbpgroup.com (2010-08-19 05:49) wrote:

$_prefs['compose_html']['value'] => 1
$mime_drivers['html']['inline'] => true,
php-5.3.2
Mozilla/5.0 (X11; U; Linux i686; fr; rv:1.9.2.8) Gecko/20100722 Firefox/3.6.8


When clicking on "Switch to plain text composition", I get no text.

Fix :
imp/lib/Ui/Compose.php:384
--            return $msg . "\n" . $sig;
++            return $data . "\n" . $sig;


I have a second issue when switching from html 2 text composition,  
accent get screwed. It appears to come from DOMDocument not being able  
to detect properly the charset.

The following fix does the job for me (inspired from "User Contributed  
Notes" http://www.php.net/manual/en/domdocument.loadhtml.php)

--- Html2text.php	2010-07-27 10:20:23.000000000 +0200
+++  
/var/www/html/horde/libs/Horde/Text/Filter/Html2text.php	2010-08-19  
12:38:34.000000000 +0200
@@ -102,16 +102,22 @@
      public function postProcess($text)
      {
          if (extension_loaded('dom')) {
-            $text = Horde_String::convertCharset($text,  
$this->_params['charset'], 'UTF-8');
+            if ($this->_params['charset'] != 'UTF-8') {
+                $text = Horde_String::convertCharset($text,  
$this->_params['charset'], 'UTF-8');
+            }

              $old_error = libxml_use_internal_errors(true);
              $doc = new DOMDocument();
-            $doc->loadHTML('<?xml encoding="UTF-8">' . $text);
+            $doc->loadHTML('<?xml encoding="UTF-8">' .  
mb_convert_encoding($text, 'HTML-ENTITIES', "UTF-8"));
              if ($old_error) {
                  libxml_use_internal_errors(false);
              }

-            $text = Horde_String::convertCharset($this->_node($doc,  
$doc), 'UTF-8', $this->_params['charset']);
+            if ($this->_params['charset'] != 'UTF-8') {
+                $text =  
Horde_String::convertCharset($this->_node($doc, $doc), 'UTF-8',  
$this->_params['charset']);
+            } else {
+                $text = $this->_node($doc, $doc);
+            }
          }







More information about the bugs mailing list