Changeset 3951 in subversion


Ignore:
Timestamp:
Sep 9, 2010 7:34:35 AM (3 years ago)
Author:
alec
Message:
  • Fix handling of charsets with LATIN-* label
Location:
trunk/roundcubemail
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/roundcubemail/CHANGELOG

    r3949 r3951  
    2020- Added fieldsets in Identity form, added 'identity_form' hook 
    2121- Re-added 'Close' button in upload form (#1486930, #1486823) 
     22- Fix handling of charsets with LATIN-* label 
    2223 
    2324RELEASE 0.4 
  • trunk/roundcubemail/program/include/main.inc

    r3946 r3951  
    335335 
    336336  $charset = preg_replace(array( 
    337     '/^[^0-9A-Z]+/',    // e.g. _ISO-8859-JP$SIO 
    338     '/\$.*$/',          // e.g. _ISO-8859-JP$SIO 
    339     '/UNICODE-1-1-*/',  // RFC1641/1642 
     337    '/^[^0-9A-Z]+/',    // e.g. _ISO-8859-JP$SIO 
     338    '/\$.*$/',          // e.g. _ISO-8859-JP$SIO 
     339    '/UNICODE-1-1-*/',  // RFC1641/1642 
     340    '/^X-/',            // X- prefix (e.g. X-ROMAN8 => ROMAN8) 
    340341    ), '', $charset); 
    341342 
     
    368369  ); 
    369370 
    370   // allow a-z and 0-9 only and remove X- prefix (e.g. X-ROMAN8 => ROMAN8) 
    371   $str = preg_replace(array('/[^A-Z0-9]/', '/^X+/'), '', $charset); 
     371  // allow A-Z and 0-9 only 
     372  $str = preg_replace('/[^A-Z0-9]/', '', $charset); 
    372373 
    373374  if (isset($aliases[$str])) 
     
    386387  else if (preg_match('/(WIN|WINDOWS)([0-9]+)/', $str, $m)) { 
    387388    $result = 'WINDOWS-' . $m[2]; 
     389    } 
     390  // LATIN 
     391  else if (preg_match('/(CSISOLATIN|LATIN)(.*)/', $str, $m)) { 
     392    $aliases = array('2' => 2, '3' => 3, '4' => 4, '5' => 9, '6' => 10, 
     393        '7' => 13, '8' => 14, '9' => 15, '10' => 16, 
     394        'ARABIC' => 6, 'CYRILLIC' => 5, 'GREEK' => 7, 'HEBREW' => 8); 
     395 
     396    // some clients sends windows-1252 text as latin1, 
     397    // it is safe to use windows-1252 for all latin1 
     398    if ($m[2] == 1) { 
     399      $result = 'WINDOWS-1252'; 
     400      } 
     401    // if iconv is not supported we need ISO labels, it's also safe for iconv 
     402    else if (!empty($aliases[$m[2]])) { 
     403      $result = 'ISO-8859-'.$aliases[$m[2]]; 
     404      } 
     405    // iconv requires convertion of e.g. LATIN-1 to LATIN1 
     406    else { 
     407      $result = $str; 
     408      } 
    388409    } 
    389410  else { 
Note: See TracChangeset for help on using the changeset viewer.