diff options
-rw-r--r-- | NEWS | 4 | ||||
-rw-r--r-- | ext/standard/mail.c | 2 | ||||
-rw-r--r-- | ext/standard/tests/mail/bug54298.phpt | 24 |
3 files changed, 29 insertions, 1 deletions
@@ -49,6 +49,10 @@ PHP NEWS - Shmop: . Fixed bug #78538 (shmop memory leak). (cmb) +- Standard: + . Fixed bug #54298 (Using empty additional_headers adding extraneous CRLF). + (cmb) + 18 Dec 2019, PHP 7.3.13 - Bcmath: diff --git a/ext/standard/mail.c b/ext/standard/mail.c index ca6ca115c2..1743e6dfbd 100644 --- a/ext/standard/mail.c +++ b/ext/standard/mail.c @@ -372,7 +372,7 @@ PHP_FUNCTION(mail) extra_cmd = php_escape_shell_cmd(ZSTR_VAL(extra_cmd)); } - if (php_mail(to_r, subject_r, message, str_headers ? ZSTR_VAL(str_headers) : NULL, extra_cmd ? ZSTR_VAL(extra_cmd) : NULL)) { + 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)) { RETVAL_TRUE; } else { RETVAL_FALSE; diff --git a/ext/standard/tests/mail/bug54298.phpt b/ext/standard/tests/mail/bug54298.phpt new file mode 100644 index 0000000000..a2ab9c83ab --- /dev/null +++ b/ext/standard/tests/mail/bug54298.phpt @@ -0,0 +1,24 @@ +--TEST-- +Bug #54298 (Using empty additional_headers adding extraneous CRLF) +--INI-- +sendmail_path=tee bug54298.eml >/dev/null +mail.add_x_header = Off +--SKIPIF-- +<?php +if (PHP_OS_FAMILY === 'Windows') die("skip Won't run on Windows"); +?> +--FILE-- +<?php +var_dump(mail('someuser@example.com', 'testsubj', 'Body part', '')); +echo file_get_contents('bug54298.eml'); +?> +--EXPECT-- +bool(true) +To: someuser@example.com +Subject: testsubj + +Body part +--CLEAN-- +<?php +unlink('bug54298.eml'); +?> |