Ticket #1485083 (closed Bugs: fixed)

Opened 4 months ago

Last modified 2 weeks ago

rcube_charset_convert() does not verify whether iconv() worked

Reported by: dog Owned by: till
Priority: 5 Milestone: 0.2-beta
Component: PHP backend Version: 0.1.1
Severity: normal Keywords:
Cc:

Description

In rcube_charset_convert() there is the following code:

  // convert charset using iconv module  
  if (function_exists('iconv') && $from != 'UTF-7' && $to != 'UTF-7')
    {
    $aliases['GB2312'] = 'GB18030';
    return iconv(($aliases[$from] ? $aliases[$from] : $from), ($aliases[$to] ? $aliases[$to] : $to) . "//IGNORE", $str);
    }

This does not verify that iconv() acutally worked. For me this resulted in getting "IMAP Error: Invalid login" errors in a shared hosting environment.

Writing the line as

$iconvRes = iconv(($aliases[$from] ? $aliases[$from] : $from), ($aliases[$to] ? $aliases[$to] : $to) . "//IGNORE", $str);
if($iconvRes !== FALSE)
	return $iconvRes;

fixed my problem.

Change History

Changed 4 months ago by alec

  • component changed from Client to PHP backend
  • milestone changed from later to 0.1.2

Changed 3 months ago by till

Can you supply an example of what caused this?

Changed 3 months ago by till

  • owner set to till
  • status changed from new to assigned
  • milestone changed from 0.1.2 to later

Added an additonal check in r1424, but please supply an example so we may be able to fix the real cause.

Changed 3 months ago by dog

Adding a breakpoint to the iconv() function reveals that it failed at

a1: UTF-7 
a2: ISO-8859-1//IGNORE 
a3: INBOX

Trying this with error_reporting shows the following message:

Notice: iconv() [function.iconv]: Wrong charset, conversion from `UTF-7' to `ISO-8859-1' is not allowed in /[...]test.php on line 10

This is in a shared hosting environment so I can not exactly say what causes this error.

Changed 2 weeks ago by alec

  • status changed from assigned to closed
  • resolution set to fixed
  • milestone changed from later to 0.2-beta

Fixed in r1424. Closing it as we haven't got test.php yet.

Changed 2 weeks ago by dog

<?php
	error_reporting(E_ALL);
	ini_set('display_errors','On');

	echo iconv("UTF-7","ISO-8859-1","INBOX");

?>

(rest of the file removed as it does not matter for the error)

I would appreciate a bit more 'proactiveness' here as the error message from PHP already says everything.

Note: See TracTickets for help on using tickets.