| | |
| | | */ |
| | | class rcube_mime |
| | | { |
| | | private static $default_charset = RCMAIL_CHARSET; |
| | | private static $default_charset; |
| | | |
| | | |
| | | /** |
| | |
| | | */ |
| | | 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 = rcube::get_instance()->config->get('default_charset', RCMAIL_CHARSET); |
| | | |
| | | if ($charset = rcube::get_instance()->config->get('default_charset')) { |
| | | return $charset; |
| | | } |
| | | |
| | | return RCMAIL_CHARSET; |
| | | } |
| | | |
| | | |
| | |
| | | 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'])) { |
| | |
| | | */ |
| | | 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 |
| | |
| | | $prefix = $regs[0]; |
| | | $level = strlen($prefix); |
| | | $line = rtrim(substr($line, $level)); |
| | | $line = $prefix . rc_wordwrap($line, $length - $level - 2, " \r\n$prefix "); |
| | | $line = $prefix . self::wordwrap($line, $length - $level - 2, " \r\n$prefix "); |
| | | } |
| | | else if ($line) { |
| | | $line = rc_wordwrap(rtrim($line), $length - 2, " \r\n"); |
| | | $line = self::wordwrap(rtrim($line), $length - 2, " \r\n"); |
| | | // space-stuffing |
| | | $line = preg_replace('/(^|\r\n)(From| |>)/', '\\1 \\2', $line); |
| | | } |