Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Mime] encoding issue with UTF-8 addresses containing doubles spaces #58592

Closed as not planned
@0xb4lint

Description

@0xb4lint

Symfony version(s) affected

3, 4, 5, 6, 7

Description

There's an issue with encoding an address header, if the name part is utf-8 and contains double spaces.

Basic example
From: Fabïen Pötencier <fabï[email protected]> encodes to:
From: =?utf-8?Q?Fab=C3=AFen?= =?utf-8?Q?P=C3=B6tencier?= <fabï[email protected]>

The problem is the doubles spaces between the two utf-8 parts, by RFC2047 6.2 those linear-white-space characters should be ignored.

More about the issue: zbateson/mail-mime-parser#244

How to reproduce

Created a basic example repository:
https://github.com/0xb4lint/mime-address-issue/blob/main/index.php

$mail = (new Symfony\Component\Mime\Email())
    ->from(new Symfony\Component\Mime\Address(
        '[email protected]',
        'fóó  bár'
    ))
    ->html('test');

And added some mail client screenshots, showing the double spaces are ignored:
https://github.com/0xb4lint/mime-address-issue/tree/main/client-screenshots

Generated mime message:

From: =?utf-8?Q?f=C3=B3=C3=B3?=  =?utf-8?Q?b=C3=A1r?= <[email protected]>
MIME-Version: 1.0
Date: Thu, 17 Oct 2024 09:08:34 +0000
Message-ID: <[email protected]>
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: quoted-printable

test

Failing tests can be found here:
0xb4lint@1478b7c

Possible Solution

I think the issue is originated from the AbstractHeader::createPhrase() function, which encodes the string word-by-word and ignored the double spaces: https://github.com/symfony/symfony/blob/7.2/src/Symfony/Component/Mime/Header/AbstractHeader.php#L88

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions