-
-
Notifications
You must be signed in to change notification settings - Fork 23
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 header lines with the correct length #25
Fold header lines with the correct length #25
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This kind of change requires careful test additions.
Perhaps it's just better to add a new api that can take headerline or headerkey,headervalue pair as input? or maybe that is not needed if the caller just passes headerline instead of headervalue as input? |
@glensc I was considering passing the whole string, but there is a problem here. If we pass the entire line, the header name will be encoded as well. But according to the RFC 2822, only the value (body) of the header must be encoded.
Will return a result like this
As you can see, in this case, the whole line breaks. So, I made the changes to be minimal and not to break past behavior. |
@Ocramius Do we have any updates? I just need this change to improve my mailing since my emails have long lines than recommended in RFC. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
@glensc can I have a second opinion? Code-wise, it makes sense, but I don't know much about RFC 2822
@Ocramius Sorry for writing a lot about this, but can we release it if everything is fine with this request? |
Makes sense to me. Spec does speak about line length irrespective to the structured content of the line. |
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>
I have made all the changes in the code to meet the requirements of the code sniffer. But now I have a problem with composer. Please check this problem.
@Ocramius can I do this in this pull request or should I open a separate pull request? Thank you. |
@danielabyan from my point of view, you can do it here 👍 |
Changes have been made to meet the requirements of composer 2.2. Composer 2.2 introduced a new security layer to prevent executing arbitrary code when the Composer runs. We have a library `dealerdirect/phpcodesniffer-composer-installer` which is executed during the installation of the project. In this commit, this library was allowed to run during the installation of the project. Signed-off-by: danielabyan <danielabyan@gmail.com>
@Ocramius I fixed all the bugs and issues that were in this pool request. Please check my work, and if everything is correct, please create a new release, as some mail services refuse to deliver my emails due to RFC complaints. Thanks a lot. |
In the old version of PHPUnit there is a bug that does not allow you to build the project. An error `Schemas parser error : Failed to locate the main schema resource at 'vendor/phpunit/phpunit/phpunit.xsd'` is thrown during the test execution. This bug has been fixed in version `9.5`. Therefore, the version of the library has been updated. Signed-off-by: danielabyan <danielabyan@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @danielabyan!
Description
According to the RFC 2822 specification (clause 2.1.1), the header length should be no more than 78 characters.
According to the specification, the length of the ENTIRE LINE should not exceed 78 characters. Currently, the
laminas-mime
library only counts the length of a value of the header.Reproducing the problem
This code will return the following result.
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.
Now, the title does not exceed 78 characters.
Note
I will wait until this pool request is merged to open my pool request on laminas-mail