Skip to content

Commit 09ebeba

Browse files
committed
Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3: Fix #54298: Using empty additional_headers adding extraneous CRLF
2 parents 68f6ab7 + ae21506 commit 09ebeba

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ PHP NEWS
8282
- Standard:
8383
. Fixed bug #79000 (Non-blocking socket stream reports EAGAIN as error).
8484
(Nikita)
85+
. Fixed bug #54298 (Using empty additional_headers adding extraneous CRLF).
86+
(cmb)
8587

8688
18 Dec 2019, PHP 7.4.1
8789

ext/standard/mail.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ PHP_FUNCTION(mail)
368368
extra_cmd = php_escape_shell_cmd(ZSTR_VAL(extra_cmd));
369369
}
370370

371-
if (php_mail(to_r, subject_r, message, str_headers ? ZSTR_VAL(str_headers) : NULL, extra_cmd ? ZSTR_VAL(extra_cmd) : NULL)) {
371+
if (php_mail(to_r, subject_r, message, str_headers && ZSTR_LEN(str_headers) ? ZSTR_VAL(str_headers) : NULL, extra_cmd ? ZSTR_VAL(extra_cmd) : NULL)) {
372372
RETVAL_TRUE;
373373
} else {
374374
RETVAL_FALSE;

ext/standard/tests/mail/bug54298.phpt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
--TEST--
2+
Bug #54298 (Using empty additional_headers adding extraneous CRLF)
3+
--INI--
4+
sendmail_path=tee bug54298.eml >/dev/null
5+
mail.add_x_header = Off
6+
--SKIPIF--
7+
<?php
8+
if (PHP_OS_FAMILY === 'Windows') die("skip Won't run on Windows");
9+
?>
10+
--FILE--
11+
<?php
12+
var_dump(mail('[email protected]', 'testsubj', 'Body part', ''));
13+
echo file_get_contents('bug54298.eml');
14+
?>
15+
--EXPECT--
16+
bool(true)
17+
18+
Subject: testsubj
19+
20+
Body part
21+
--CLEAN--
22+
<?php
23+
unlink('bug54298.eml');
24+
?>

0 commit comments

Comments
 (0)