Skip to content

Commit d7833fd

Browse files
committed
Merge branch 'PHP-7.4'
* PHP-7.4: Fix #54298: Using empty additional_headers adding extraneous CRLF
2 parents 29df9d1 + 09ebeba commit d7833fd

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

ext/standard/mail.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ PHP_FUNCTION(mail)
333333
extra_cmd = php_escape_shell_cmd(ZSTR_VAL(extra_cmd));
334334
}
335335

336-
if (php_mail(to_r, subject_r, message, headers_str ? ZSTR_VAL(headers_str) : NULL, extra_cmd ? ZSTR_VAL(extra_cmd) : NULL)) {
336+
if (php_mail(to_r, subject_r, message, headers_str && ZSTR_LEN(headers_str) ? ZSTR_VAL(headers_str) : NULL, extra_cmd ? ZSTR_VAL(extra_cmd) : NULL)) {
337337
RETVAL_TRUE;
338338
} else {
339339
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)