php-imap
php-imap copied to clipboard
Address personal field is not decoded
Personal field in Address class should also be decoded. From, To, CC, and Bcc are affected by this bug.
use Webklex\PHPIMAP\Address;
/** @var Address $from */
$from = $mail->getFrom()->first();
// COMPANYNAME | =?iso-8859-2?q?us=B3ugi?
echo $from->personal;
// COMPANYNAME | usługi
echo mb_decode_mimeheader($from->personal);
/** @var Address $address */
foreach ($mail->getTo()->all() as $address) {
echo $address->personal;
}
Expected behavior
It seems the Header->decode method should also be applied to the personal field inside Header->decodeAddresses, in the same way it is applied to the subject inside Header->parse.
Desktop / Server:
- OS: Alpine:3.20.2
- PHP: 8.3
- Version: php-imap 5.5.0
- Provider: Unknown, old, on premise in the private company
The problem also exists when the subject is encoded as UTF-8, like that:
// =?utf-8?B?UkU6IFtFWFRFUk5BTF0gUmU6IExvcmVtIElwc3VtIC8=?= =?utf-8?Q?40_one?=
echo $mail->getSubject();
// RE: [EXTERNAL] Re: Lorem Ipsum / 40 one
echo mb_decode_mimeheader($mail->getSubject());
The problem persists when the imap extension is not loaded. Version: php-imap 6.1.0.