Changeset 1490 in subversion
- Timestamp:
- Jun 7, 2008 2:48:59 PM (5 years ago)
- Location:
- trunk/roundcubemail/program/include
- Files:
-
- 2 edited
-
rcube_imap.php (modified) (2 diffs)
-
rcube_shared.inc (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/roundcubemail/program/include/rcube_imap.php
r1480 r1490 1160 1160 $struct->parts[] = $this->_structure_part($part[8], ++$count, $struct->mime_id); 1161 1161 } 1162 1162 1163 1163 // normalize filename property 1164 1164 if ($filename_mime = $struct->d_parameters['filename'] ? $struct->d_parameters['filename'] : $struct->ctype_parameters['name']) 1165 $struct->filename = rcube_imap::decode_mime_string($filename_mime, $this->default_charset); 1165 { 1166 $struct->filename = rcube_imap::decode_mime_string($filename_mime, 1167 $struct->charset ? $struct->charset : rc_detect_encoding($filename_mime, $this->default_charset)); 1168 } 1166 1169 else if ($filename_encoded = $struct->d_parameters['filename*'] ? $struct->d_parameters['filename*'] : $struct->ctype_parameters['name*']) 1167 1170 { … … 1171 1174 } 1172 1175 else if (!empty($struct->headers['content-description'])) 1173 $struct->filename = rcube_imap::decode_mime_string($struct->headers['content-description'], $this->default_charset); 1176 $struct->filename = rcube_imap::decode_mime_string($struct->headers['content-description'], 1177 $struct->charset ? $struct->charset : rc_detect_encoding($struct->headers['content-description'],$this->default_charset)); 1174 1178 1175 1179 return $struct; -
trunk/roundcubemail/program/include/rcube_shared.inc
r1360 r1490 582 582 } 583 583 584 585 /** 586 * A method to guess encoding of a string. 587 * 588 * @param string $string String. 589 * @param string $failover Default result for failover. 590 * 591 * @return string 592 */ 593 function rc_detect_encoding($string, $failover='') 594 { 595 if (!function_exists('mb_detect_encoding')) { 596 return $failover; 597 } 598 599 // FIXME: the order is important, because sometimes 600 // iso string is detected as euc-jp and etc. 601 $enc = array( 602 'UTF-8', 'ISO-8859-1', 'ISO-8859-2', 'ISO-8859-3', 'ISO-8859-4', 603 'ISO-8859-5', 'ISO-8859-6', 'ISO-8859-7', 'ISO-8859-8', 'ISO-8859-9', 604 'ISO-8859-10', 'ISO-8859-13', 'ISO-8859-14', 'ISO-8859-15', 'ISO-8859-16', 605 'WINDOWS-1252', 'WINDOWS-1251', 'EUC-JP', 'EUC-TW', 'KOI8-R' 606 ); 607 608 $result = mb_detect_encoding($string, join(',', $enc)); 609 610 return $result ? $result : $failover; 611 } 612 584 613 ?>
Note: See TracChangeset
for help on using the changeset viewer.
