Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fold a string with the correct length #174

Merged
merged 3 commits into from
Sep 20, 2022
Merged

Fold a string with the correct length #174

merged 3 commits into from
Sep 20, 2022

Conversation

danielabyan
Copy link
Contributor

@danielabyan danielabyan commented Oct 21, 2021

Q A
Documentation no
Bugfix yes
BC Break yes
New Feature no
RFC yes
QA no

Description

According to the RFC 2822 specification (clause 2.1.1), the header length should be no more than 78 characters.

Each line of characters MUST be no more than 998 characters, and SHOULD be no more than 78 characters, excluding the CRLF.

According to the specification, the length of the ENTIRE LINE should not exceed 78 characters. Currently, the laminas-mail library only counts the length of a value of the header.

Reproducing the problem

$message = new Message();
$message->addFrom('matthew@example.org', 'Matthew Somelli');
$message->addTo('foobar@example.com');
$message->setSubject('xxxxx xxxxx xxxxx xxxxx xxxxx xxxxx xxxxx xxxxx xxxxx xxxxx xxxxx xxxxx xxxxx');
$message->setBody('This is the message body.');

echo $message->toString();

This code will return the following result.

Date: Thu, 21 Oct 2021 09:59:33 +0000
From: Matthew Somelli matthew@example.org
To: foobar@example.com
Subject: xxxxx xxxxx xxxxx xxxxx xxxxx xxxxx xxxxx xxxxx xxxxx xxxxx xxxxx xxxxx xxxxx

This is the message body.

As you can see from the example, the header is longer than 78 characters.

New code behavior

This commit has fixed this issue. In this pool request, the code above will return the following result.

Date: Thu, 21 Oct 2021 10:04:43 +0000
From: Matthew Somelli matthew@example.org
To: foobar@example.com
Subject: xxxxx xxxxx xxxxx xxxxx xxxxx xxxxx xxxxx xxxxx xxxxx xxxxx xxxxx
xxxxx xxxxx

This is the message body.

Now, the title does not exceed 78 characters.

Note

Waiting for pooling request on laminas-mime

src/Header/HeaderWrap.php Outdated Show resolved Hide resolved
@danielabyan danielabyan marked this pull request as ready for review November 15, 2021 07:50
@Ocramius Ocramius changed the base branch from 2.16.x to 2.17.x February 23, 2022 21:09
@danielabyan danielabyan changed the base branch from 2.17.x to 2.18.x September 19, 2022 14:55
@Ocramius Ocramius added the Bug Something isn't working label Sep 19, 2022
@Ocramius Ocramius added this to the 2.18.0 milestone Sep 19, 2022
According to the RFC 2822 specification (clause 2.1.1),
the header length should be no more than 78 characters.
   "Each line of characters MUST be no more than 998
   characters, and SHOULD be no more than 78 characters,
   excluding the CRLF."
According to the specification, the length of the ENTIRE
LINE should not exceed 78 characters. Currently, the
`laminas-mail` library only counts the length of a value
of the header. This commit has fixed this issue.

Signed-off-by: danielabyan <danielabyan@gmail.com>
In order for the change to take effect, it is necessary
to update the `laminas/laminas-mime` library.

Signed-off-by: danielabyan <danielabyan@gmail.com>
Signed-off-by: danielabyan <danielabyan@gmail.com>
@Slamdunk Slamdunk merged commit 0976a33 into laminas:2.18.x Sep 20, 2022
@Ocramius Ocramius assigned Ocramius and Slamdunk and unassigned Ocramius Sep 20, 2022
@danielabyan danielabyan deleted the feature/fold-header-properly branch September 20, 2022 08:33
artemii-karkusha pushed a commit to artemii-karkusha/laminas-mail that referenced this pull request May 24, 2023
…roperly

Fold a string with the correct length
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants