diff options
author | Aleksander Machniak <alec@alec.pl> | 2012-06-06 09:22:15 +0200 |
---|---|---|
committer | Aleksander Machniak <alec@alec.pl> | 2012-06-06 09:22:15 +0200 |
commit | 0f5dee00df59dd2f97c36aa0fc3aca062f9d223a (patch) | |
tree | 63d4629faeacae61ff7f6ed383b3382e008f7921 /program/include | |
parent | 0b6d022e6fa9dc08ddbc8ba420cdd58a690cf852 (diff) |
Decode header value in rcube_mime::get() by default (#1488511)
Diffstat (limited to 'program/include')
-rw-r--r-- | program/include/rcube_message_header.php | 9 | ||||
-rw-r--r-- | program/include/rcube_mime.php | 24 |
2 files changed, 26 insertions, 7 deletions
diff --git a/program/include/rcube_message_header.php b/program/include/rcube_message_header.php index f2f91674e..378fb98c9 100644 --- a/program/include/rcube_message_header.php +++ b/program/include/rcube_message_header.php @@ -205,15 +205,18 @@ class rcube_message_header /** * Returns header value */ - public function get($name) + public function get($name, $decode = true) { $name = strtolower($name); if (isset($this->obj_headers[$name])) { - return $this->{$this->obj_headers[$name]}; + $value = $this->{$this->obj_headers[$name]}; + } + else { + $value = $this->others[$name]; } - return $this->others[$name]; + return $decode ? rcube_mime::decode_header($value, $this->charset) : $value; } /** diff --git a/program/include/rcube_mime.php b/program/include/rcube_mime.php index 9a594f3ee..53655a9cb 100644 --- a/program/include/rcube_mime.php +++ b/program/include/rcube_mime.php @@ -42,9 +42,25 @@ class rcube_mime if ($default_charset) { self::$default_charset = $default_charset; } - else { - self::$default_charset = rcube::get_instance()->config->get('default_charset', RCMAIL_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; } + + if ($charset = rcube::get_instance()->config->get('default_charset')) { + return $charset; + } + + return RCMAIL_CHARSET; } @@ -89,7 +105,7 @@ class rcube_mime 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(); // determine filename if (($filename = $part->d_parameters['filename']) || ($filename = $part->ctype_parameters['name'])) { @@ -183,7 +199,7 @@ class rcube_mime */ 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 |