Ticket #1484565: roundcube-iconv-fix.patch

File roundcube-iconv-fix.patch, 1.0 kB (added by memoryhole, 14 months ago)

A patch that fixes the problem (with charset aliasing to fix typical mis-labelling)

  • include/main.inc

     
    10621062  if ($from==$to || $str=='' || empty($from)) 
    10631063    return $str; 
    10641064 
     1065  // These make up for most common mis-labellings noted in the wild, and are 
     1066  // harmless 
     1067  if ($from == 'X-UNKNOWN' || $from == 'UNKNOWN-8BIT' || $from == 'X-USER-DEFINED' || $from == 'ISO-8859-1' || $from == 'US-ASCII') 
     1068          $from = 'WINDOWS-1252'; 
     1069  if ($from == 'ISO-8859-8-I') $from = 'ISO-8859-8'; 
     1070  if ($from == 'GB2312') $from = 'GB18030'; 
     1071 
    10651072  // convert charset using iconv module   
    10661073  if (function_exists('iconv') && $from != 'UTF-7' && $to != 'UTF-7') 
    1067     return iconv($from, $to . "//IGNORE", $str); 
     1074  { 
     1075        $retstr = iconv($from, $to . "//IGNORE", $str); 
     1076        if (!$retstr) { 
     1077          return iconv('US-ASCII', $to . "//IGNORE", $str); 
     1078        } 
     1079        return $retstr; 
     1080  } 
    10681081 
    10691082  // convert charset using mbstring module   
    10701083  if ($MBSTRING)