Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#1485083 closed Bugs (fixed)

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 (6)

comment:1 Changed 5 years ago by alec

  • Component changed from Client to PHP backend
  • Milestone changed from later to 0.1.2

comment:2 Changed 5 years ago by till

Can you supply an example of what caused this?

comment:3 Changed 5 years ago by till

  • Milestone changed from 0.1.2 to later
  • Owner set to till
  • Status changed from new to assigned

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

comment:4 Changed 5 years 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.

comment:5 Changed 5 years ago by alec

  • Milestone changed from later to 0.2-beta
  • Resolution set to fixed
  • Status changed from assigned to closed

Fixed in [3bfab3b9]. Closing it as we haven't got test.php yet.

comment:6 Changed 5 years 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.