php-imap icon indicating copy to clipboard operation
php-imap copied to clipboard

Address personal field is not decoded

Open wkania opened this issue 1 year ago • 2 comments

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

wkania avatar Aug 28 '24 08:08 wkania

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

wkania avatar Sep 04 '24 10:09 wkania

The problem persists when the imap extension is not loaded. Version: php-imap 6.1.0.

mob6085 avatar Jan 19 '25 21:01 mob6085