Cyrus + php Net/IMAP & encoding
Pieter Vanmeerbeek
pieter.vanmeerbeek at able.be
Wed Oct 4 10:55:50 EDT 2006
Hi,
I'm struggling with the encoding of my cyrus installation.
I have a folder Calendar Partagé , which is stored and known by cyrus as
'user/pv/Calendrier partag&AOk-'
However the same folder needs to be consulted by a php process, using
Net/IMAP.php module.
The default setting for this module is a special utf_7 + base 64 encoding
(which seems to be declared by RFC 3501).
If I try to access this folder using the module I'm getting an error :
Error: Folder: user/pv/Calendrier partagé, [pear_error: message="NO, Mailbox
does not exist" code=0 mode=return level=notice prefix="" info=""]
Further investigation shows that the php module encodes the folder name to
"user/pv/Calendrier partag&w6k-", which differs from the cyrus storage
format.
Manually setting the foldername to the storage format of cyrus does the
trick.
Is there anyone experiencing the same problem as I am?
I'm using PHP 4.4.2, cyrus 2.2.12, Net_IMAP 1.0.3.
Kin regards
Pieter
PS this is the encoding from php :
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>
function utf_7_encode($str)
{
if($this->_useUTF_7 == false ){
return $str;
}
//return imap_utf7_encode($str);
$encoded_utf7 = '';
$base64_part = '';
if(is_array($str)){
return new PEAR_Error('error');
}
for ($i = 0; $i < strlen($str); $i++) {
//those chars should be base64 encoded
if ( ((ord($str[$i]) >= 39 ) and (ord($str[$i]) <= 126 )) or
((ord($str[$i]) >= 32 ) and (ord($str[$i]) <= 37 )) ) {
if ($base64_part) {
$encoded_utf7 = sprintf("%s&%s-", $encoded_utf7,
str_replace('=', '',base64_encode($base64_part)) );
$base64_part = '';
}
$encoded_utf7 = sprintf("%s%s",$encoded_utf7 , $str[$i]);
} else {
//handle &
if (ord($str[$i]) == 38 ) {
if ($base64_part) {
$encoded_utf7 = sprintf("%s&%s-", $encoded_utf7,
str_replace('=', '',base64_encode($base64_part)) );
$base64_part = '';
}
$encoded_utf7 = sprintf("%s&-", $encoded_utf7 );
} else {
$base64_part = sprintf("%s%s",$base64_part , $str[$i]);
//$base64_part = sprintf("%s%s%s",$base64_part , chr(0)
, $str[$i]);
}
}
}
if ($base64_part) {
$encoded_utf7 = sprintf("%s&%s-", $encoded_utf7,
str_replace('=', '',base64_encode($base64_part)) );
$base64_part = '';
}
return $encoded_utf7;
}
--
---------------------------------------------------
Able: 1996-2006: already 10 safe years in YOUR company!
aXs GUARD has completed security and anti-virus checks on this e-mail (http://www.axsguard.com)
---------------------------------------------------
Able NV: ond.nr 0457.938.087
RPR Mechelen
More information about the Info-cyrus
mailing list