imap icon indicating copy to clipboard operation
imap copied to clipboard

UTF7-IMAP encoding problems

Open jordisalord opened this issue 4 years ago • 4 comments

Hi there, at line 210 of file Connection.php this UTF8 conversion is giving me some problems reading an office365 server.

foreach ($mailboxesInfo as $mailboxInfo) { $name = \mb_convert_encoding(\str_replace($this->server, '', $mailboxInfo->name), 'UTF-8', 'UTF7-IMAP'); $this->mailboxNames[$name] = $mailboxInfo; }

It would be much better to do the conversion like this: $name=\mb_convert_encoding($cleanname, 'UTF8', mb_detect_encoding(\str_replace($this->server, '', $mailboxInfo->name)));

jordisalord avatar Apr 13 '21 15:04 jordisalord

What exactly are the issues you have?

Slamdunk avatar Apr 14 '21 06:04 Slamdunk

What exactly are the issues you have?

Office365 server is returning ASCII encoding, not UTF7, so the result of mb_convert_enconding() is empty.

As a result, you can't fetch the Mailboxes (because the script uses its name as identifier inside the array).

jordisalord avatar Apr 14 '21 06:04 jordisalord

I figured out I copied/pasted the purposal too fast. $cleanname variable is the result of: $cleanname = str_replace($this->server, '', $mailboxInfo->name);

Then you do: $name=\mb_convert_encoding($cleanname, 'UTF8', mb_detect_encoding($cleanname));

jordisalord avatar Apr 14 '21 06:04 jordisalord

Office365 server is returning ASCII encoding, not UTF7

That would be very weird and out of standards, but I'm not surprised.

May you post here the UTF8 encoded name of the mailbox you are using, so I can reconvert it into ASCII in the Test Suite and write a dedicated test?

Slamdunk avatar Apr 14 '21 06:04 Slamdunk