php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #54298 Using empty additional_headers adding extraneous CRLF
Submitted: 2011-03-17 18:28 UTC Modified: 2020-01-06 13:53 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: anrdaemon at freemail dot ru Assigned: cmb (profile)
Status: Closed Package: Mail related
PHP Version: Irrelevant OS: Win32/*NIX32
Private report: No CVE-ID: None
 [2011-03-17 18:28 UTC] 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));


Patches

Add a Patch

Pull Requests

Pull requests:

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-01-05 14:19 UTC] cmb@php.net
-Status: Open +Status: Verified
 [2020-01-05 14:19 UTC] 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.
 [2020-01-05 14:19 UTC] cmb@php.net
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
 [2020-01-06 13:51 UTC] cmb@php.net
Automatic comment on behalf of cmbecker69@gmx.de
Revision: http://git.php.net/?p=php-src.git;a=commit;h=ae2150692a9a2e0878314385d03826f160e6a76a
Log: Fix #54298: Using empty additional_headers adding extraneous CRLF
 [2020-01-06 13:51 UTC] cmb@php.net
-Status: Verified +Status: Closed
 [2020-01-06 13:53 UTC] cmb@php.net
-Assigned To: +Assigned To: cmb
 [2020-01-07 13:16 UTC] anrdaemon at yandex dot ru
Submitted:	2011-03-17 18:28 UTC

[2020-01-06 13:51 UTC] cmb@php.net 
-Status: Verified
+Status: Closed

*khm*
Many thanks for this Christmas gift.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 21:01:27 2024 UTC