Bug #54298 [PATCH]: Using empty additional_headers adding extraneous CRLF
| From: | cmb@php.net | Date: | Sun, 05 Jan 2020 14:19:33 +0000 |
| Subject: | Bug #54298 [PATCH]: Using empty additional_headers adding extraneous CRLF | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-224716@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=54298&edit=1
ID: 54298
Patch added by: cmb@php.net
Reported by: anrdaemon at freemail dot ru
Summary: Using empty additional_headers adding extraneous
CRLF
Status: Verified
Type: Bug
Package: Mail related
Operating System: Win32/*NIX32
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
The following pull request has been associated:
Patch Name: Fix #54298: Using empty additional_headers adding extraneous CRLF
On GitHub: https://github.com/php/php-src/pull/5055
Patch: https://github.com/php/php-src/pull/5055.patch
Previous Comments:
------------------------------------------------------------------------
[2020-01-05 14:19:13] cmb@php.net
As of PHP 7.2.0, there's no need anymore to implode() the array,
since $additional_headers accepts an array in the first place.
Doing so won't add the extraneous line break, so this issue is
partially resolved. Still, when passing an empty string, there
should be no extraneous line break.
------------------------------------------------------------------------
[2011-03-17 18:28:09] anrdaemon at freemail dot ru
Description:
------------
Using the code sample below, you could see that it adds a "\r\n" to the end of the mail
headers irrelevant to $additional_headers containing a meaningful value.
Even using an
empty($addParams) ? NULL/false : implode()
replacement, it does not fix the problem. The resulting message will still start from second line.
Which is bad for look.
To beat it, you're forced to check for empty($addParams) before invoking mail() (and to have
two separate mail() lines in your code, which does not lead to the code clarity)...
Test script:
---------------
<?php
$addParams = array();
mail('someuser@example.com', 'testsubj', 'Body part',
implode("\r\n", $addParams));
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=54298&edit=1