From 95cec992ebe4dcaab5daae20f11b2e37d577b2d7 Mon Sep 17 00:00:00 2001
From: Aleksander Machniak <alec@alec.pl>
Date: Wed, 15 Aug 2012 03:09:29 -0400
Subject: [PATCH] Fix stripped apostrophes when replying in plain text to HTML message (#1488606)
---
program/include/rcube_mime.php | 32 +++++++++++++++++++++++---------
1 files changed, 23 insertions(+), 9 deletions(-)
diff --git a/program/include/rcube_mime.php b/program/include/rcube_mime.php
index bc0b2aa..287bde8 100644
--- a/program/include/rcube_mime.php
+++ b/program/include/rcube_mime.php
@@ -34,7 +34,7 @@
*/
class rcube_mime
{
- private static $default_charset = RCMAIL_CHARSET;
+ private static $default_charset;
/**
@@ -42,12 +42,26 @@
*/
function __construct($default_charset = null)
{
- if ($default_charset) {
- self::$default_charset = $default_charset;
+ self::$default_charset = $default_charset;
+ }
+
+
+ /**
+ * Returns message/object character set name
+ *
+ * @return string Characted set name
+ */
+ public static function get_charset()
+ {
+ if (self::$default_charset) {
+ return self::$default_charset;
}
- else {
- self::$default_charset = rcmail::get_instance()->config->get('default_charset', RCMAIL_CHARSET);
+
+ if ($charset = rcmail::get_instance()->config->get('default_charset')) {
+ return $charset;
}
+
+ return RCMAIL_CHARSET;
}
@@ -92,15 +106,15 @@
if ($part->ctype_parameters['charset'])
$struct->charset = $part->ctype_parameters['charset'];
- $part_charset = $struct->charset ? $struct->charset : self::$default_charset;
+ $part_charset = $struct->charset ? $struct->charset : self::get_charset();
- // TODO: determine filename
+ // determine filename
if (($filename = $part->d_parameters['filename']) || ($filename = $part->ctype_parameters['name'])) {
$struct->filename = rcube_mime::decode_mime_string($filename, $part_charset);
}
// copy part body and convert it to UTF-8 if necessary
- $struct->body = $part->ctype_primary == 'text' ? rcube_charset::convert($part->body, $part_charset) : $part->body;
+ $struct->body = $part->ctype_primary == 'text' || !$part->ctype_parameters['charset'] ? rcube_charset::convert($part->body, $part_charset) : $part->body;
$struct->size = strlen($part->body);
$struct->disposition = $part->disposition;
@@ -186,7 +200,7 @@
*/
public static function decode_mime_string($input, $fallback = null)
{
- $default_charset = !empty($fallback) ? $fallback : self::$default_charset;
+ $default_charset = !empty($fallback) ? $fallback : self::get_charset();
// rfc: all line breaks or other characters not found
// in the Base64 Alphabet must be ignored by decoding software
--
Gitblit v1.9.1