-
-
Notifications
You must be signed in to change notification settings - Fork 178
Description
Describe the bug
Currently Webklex/php-imap by default uses 'utf-8' decoder and \imap_utf8()
function to decode subject:
Line 424 in abf080e
if ($decoder === 'utf-8' && extension_loaded('imap')) { |
This approach does not always decode subjects properly.
For example Subject: =?ISO-2022-JP?B?GyRCIXlCaBsoQjEzMhskQjlmISEhViUsITwlRyVzGyhCJhskQiUoJS8lOSVGJWolIiFXQGxMZ0U5JE4kPyRhJE4jURsoQiYbJEIjQSU1JW0lcyEhIVo3bjQpJSglLyU5JUYlaiUiISYlbyE8JS8hWxsoQg==?=
will be decoded into garbled string:
�$B!yBh�(B132�$B9f!!!V%,!<%G%s�(B&�$B%(%/%9%F%j%"!W@lLgE9$N$?$a$N#Q�(B&�$B#A%5%m%s!!!Z7n4)%(%/%9%F%j%"!&%o!<%/![�(B
So it does not make much sense to use by default the approach which is not 100% reliable.
Some time ago we've switched to decoding the subject simply with iconv_mime_decode()
:
$value = iconv_mime_decode($value, ICONV_MIME_DECODE_CONTINUE_ON_ERROR, "UTF-8");
It works always and properly - freescout-help-desk/freescout#2965 (comment).
So maybe it worth making iconv_mime_decode()
the default and the only approach for decoding the subject like this: https://github.com/freescout-helpdesk/freescout/blob/master/overrides/webklex/php-imap/src/Header.php#L208
Function:
https://github.com/freescout-helpdesk/freescout/blob/dist/app/Misc/Mail.php#L909 (decodeSubject()
)
Related issue: Webklex/laravel-imap#295