- Fix handling of charsets with LATIN-* label

release-0.6
alecpl 14 years ago
parent 71f60cc9aa
commit 4d7acb3cb2

@ -19,6 +19,7 @@ CHANGELOG RoundCube Webmail
- Show disabled checkboxes for protected folders instead of dots (#1485498) - Show disabled checkboxes for protected folders instead of dots (#1485498)
- Added fieldsets in Identity form, added 'identity_form' hook - Added fieldsets in Identity form, added 'identity_form' hook
- Re-added 'Close' button in upload form (#1486930, #1486823) - Re-added 'Close' button in upload form (#1486930, #1486823)
- Fix handling of charsets with LATIN-* label
RELEASE 0.4 RELEASE 0.4
----------- -----------

@ -334,9 +334,10 @@ function rcube_parse_charset($input)
return $charsets[$input]; return $charsets[$input];
$charset = preg_replace(array( $charset = preg_replace(array(
'/^[^0-9A-Z]+/', // e.g. _ISO-8859-JP$SIO '/^[^0-9A-Z]+/', // e.g. _ISO-8859-JP$SIO
'/\$.*$/', // e.g. _ISO-8859-JP$SIO '/\$.*$/', // e.g. _ISO-8859-JP$SIO
'/UNICODE-1-1-*/', // RFC1641/1642 '/UNICODE-1-1-*/', // RFC1641/1642
'/^X-/', // X- prefix (e.g. X-ROMAN8 => ROMAN8)
), '', $charset); ), '', $charset);
# Aliases: some of them from HTML5 spec. # Aliases: some of them from HTML5 spec.
@ -367,8 +368,8 @@ function rcube_parse_charset($input)
'128' => 'SHIFT-JIS' '128' => 'SHIFT-JIS'
); );
// allow a-z and 0-9 only and remove X- prefix (e.g. X-ROMAN8 => ROMAN8) // allow A-Z and 0-9 only
$str = preg_replace(array('/[^A-Z0-9]/', '/^X+/'), '', $charset); $str = preg_replace('/[^A-Z0-9]/', '', $charset);
if (isset($aliases[$str])) if (isset($aliases[$str]))
$result = $aliases[$str]; $result = $aliases[$str];
@ -386,6 +387,26 @@ function rcube_parse_charset($input)
else if (preg_match('/(WIN|WINDOWS)([0-9]+)/', $str, $m)) { else if (preg_match('/(WIN|WINDOWS)([0-9]+)/', $str, $m)) {
$result = 'WINDOWS-' . $m[2]; $result = 'WINDOWS-' . $m[2];
} }
// LATIN
else if (preg_match('/(CSISOLATIN|LATIN)(.*)/', $str, $m)) {
$aliases = array('2' => 2, '3' => 3, '4' => 4, '5' => 9, '6' => 10,
'7' => 13, '8' => 14, '9' => 15, '10' => 16,
'ARABIC' => 6, 'CYRILLIC' => 5, 'GREEK' => 7, 'HEBREW' => 8);
// some clients sends windows-1252 text as latin1,
// it is safe to use windows-1252 for all latin1
if ($m[2] == 1) {
$result = 'WINDOWS-1252';
}
// if iconv is not supported we need ISO labels, it's also safe for iconv
else if (!empty($aliases[$m[2]])) {
$result = 'ISO-8859-'.$aliases[$m[2]];
}
// iconv requires convertion of e.g. LATIN-1 to LATIN1
else {
$result = $str;
}
}
else { else {
$result = $charset; $result = $charset;
} }

Loading…
Cancel
Save