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:29:15 +0200 |
commit | 0e5821166bcffa4a370053fb4432310adb78929c (patch) | |
tree | b832df54fb77647305b3f423766521214eba7635 /program | |
parent | 7a259c601b4c9c69615411b6da91ff25b79079e0 (diff) |
Decode header value in rcube_mime::get() by default (#1488511)
Conflicts:
program/include/rcube_message_header.php
program/include/rcube_mime.php
Diffstat (limited to 'program')
-rw-r--r-- | program/include/rcube_imap_generic.php | 9 | ||||
-rw-r--r-- | program/include/rcube_mime.php | 28 |
2 files changed, 27 insertions, 10 deletions
diff --git a/program/include/rcube_imap_generic.php b/program/include/rcube_imap_generic.php index 29dff8613..0ae82eaca 100644 --- a/program/include/rcube_imap_generic.php +++ b/program/include/rcube_imap_generic.php @@ -83,15 +83,18 @@ class rcube_mail_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 538c8ea45..287bde851 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 @@ class rcube_mime */ 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,7 +106,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'])) { @@ -186,7 +200,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 |