Skip to content

Mail subject not decoded #619

@darkelfe14728

Description

@darkelfe14728

Mail subject is not decoded with decoder = "utf-8" and IMAP extension not present.

Configuration

'options' => [
    'decoder' => [
        'message'    => 'utf-8',
        'attachment' => 'utf-8',
    ]
]

And IMAP extension not present (function "imap_mime_header_decode" not available).

Exemple
Mail with the following subjet :

=?utf-8?B?I01JNjQ4MiA6IERvY3VtZW50cyAtIE1tZSBMYW7DqWUgLSBNSTI2MDUwNDYy?= =?utf-8?Q?3?=

Is not decoded and return as is

Additional context
In "Header" class, the method "mime_header_decode" works as intended (decoding MIME header element) only if IMAP extension is active. If not, only convert the encoding to UTF-8.

The "decode" method (called during header parsing) provide other methods to do this, but they are nether used because, when the decoder is "utf-8", the "$tempValue" is never empty.

The related code section :

if ($decoder === 'utf-8') {
    $decoded_values = $this->mime_header_decode($value);
    $tempValue = "";
    foreach ($decoded_values as $decoded_value) {
        $tempValue .= $this->convertEncoding($decoded_value->text, $decoded_value->charset);
    }

    if ($tempValue) {
        $value = $tempValue;
    } else if (extension_loaded('imap')) {
        $value = \imap_utf8($value);
    }else if (function_exists('iconv_mime_decode')){
        $value = iconv_mime_decode($value, ICONV_MIME_DECODE_CONTINUE_ON_ERROR, "UTF-8");
    }else{
        $value = mb_decode_mimeheader($value);
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions