diff options
author | Stanislav Malyshev <stas@php.net> | 2015-06-28 20:23:00 -0700 |
---|---|---|
committer | Stanislav Malyshev <stas@php.net> | 2015-06-28 20:23:00 -0700 |
commit | 8f2e08239fc1f8aabc26398393303fa685e810dd (patch) | |
tree | d608ca94bc73cc9d59daa9a3144f35b195911665 | |
parent | 80f9a9725c1ec4975e92889a464856c092c4bc4c (diff) | |
parent | cd9c39d77ce22e5e377f9f23474c20374d76a10a (diff) | |
download | php-git-8f2e08239fc1f8aabc26398393303fa685e810dd.tar.gz |
Merge branch 'PHP-5.4' into PHP-5.5
* PHP-5.4:
Move strlen() check to php_mail_detect_multiple_crlf()
Fixed Bug #69874 : Can't set empty additional_headers for mail()
-rw-r--r-- | ext/standard/mail.c | 6 | ||||
-rw-r--r-- | ext/standard/tests/mail/bug69874.phpt | 42 | ||||
-rw-r--r-- | ext/standard/tests/mail/bug69874_2.phpt | 43 |
3 files changed, 88 insertions, 3 deletions
diff --git a/ext/standard/mail.c b/ext/standard/mail.c index 09e0a5546b..17c09dbcaa 100644 --- a/ext/standard/mail.c +++ b/ext/standard/mail.c @@ -226,7 +226,7 @@ void php_mail_log_to_file(char *filename, char *message, size_t message_size TSR static int php_mail_detect_multiple_crlf(char *hdr) { /* This function detects multiple/malformed multiple newlines. */ - if (!hdr) { + if (!hdr || !strlen(hdr)) { return 0; } @@ -321,7 +321,7 @@ PHPAPI int php_mail(char *to, char *subject, char *message, char *headers, char php_basename(tmp, strlen(tmp), NULL, 0,&f, &f_len TSRMLS_CC); - if (headers != NULL) { + if (headers != NULL && *headers) { spprintf(&hdr, 0, "X-PHP-Originating-Script: %ld:%s\n%s", php_getuid(TSRMLS_C), f, headers); } else { spprintf(&hdr, 0, "X-PHP-Originating-Script: %ld:%s", php_getuid(TSRMLS_C), f); @@ -429,7 +429,7 @@ PHPAPI int php_mail(char *to, char *subject, char *message, char *headers, char php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not execute mail delivery program '%s'", sendmail_path); #if PHP_SIGCHILD if (sig_handler) { - signal(SIGCHLD, sig_handler); + signal(SIGCHLD, sig_handler); } #endif MAIL_RET(0); diff --git a/ext/standard/tests/mail/bug69874.phpt b/ext/standard/tests/mail/bug69874.phpt new file mode 100644 index 0000000000..a952a73bdc --- /dev/null +++ b/ext/standard/tests/mail/bug69874.phpt @@ -0,0 +1,42 @@ +--TEST-- +Bug #69874: Null addtional_headers does not send mail +--INI-- +sendmail_path=tee mailBasic.out >/dev/null +mail.add_x_header = Off +--SKIPIF-- +<?php +if(substr(PHP_OS, 0, 3) == "WIN") + die("skip Won't run on Windows"); +?> +--FILE-- +<?php +/* Prototype : int mail(string to, string subject, string message [, string additional_headers [, string additional_parameters]]) + * Description: Send an email message + * Source code: ext/standard/mail.c + * Alias to functions: + */ + +echo "*** Testing mail() : send email without additional headers ***\n"; + +// Initialise all required variables +$to = 'user@company.com'; +$subject = 'Test Subject'; +$message = 'A Message'; + +$outFile = "mailBasic.out"; +@unlink($outFile); + +var_dump( mail($to, $subject, $message) ); +echo file_get_contents($outFile); +unlink($outFile); + +?> +===DONE=== +--EXPECTF-- +*** Testing mail() : send email without additional headers *** +bool(true) +To: user@company.com +Subject: Test Subject + +A Message +===DONE=== diff --git a/ext/standard/tests/mail/bug69874_2.phpt b/ext/standard/tests/mail/bug69874_2.phpt new file mode 100644 index 0000000000..53d991a26b --- /dev/null +++ b/ext/standard/tests/mail/bug69874_2.phpt @@ -0,0 +1,43 @@ +--TEST-- +Bug #69874: Null addtional_headers does not send mail +--INI-- +sendmail_path=tee mailBasic.out >/dev/null +mail.add_x_header = On +--SKIPIF-- +<?php +if(substr(PHP_OS, 0, 3) == "WIN") + die("skip Won't run on Windows"); +?> +--FILE-- +<?php +/* Prototype : int mail(string to, string subject, string message [, string additional_headers [, string additional_parameters]]) + * Description: Send an email message + * Source code: ext/standard/mail.c + * Alias to functions: + */ + +echo "*** Testing mail() : send email without additional headers ***\n"; + +// Initialise all required variables +$to = 'user@company.com'; +$subject = 'Test Subject'; +$message = 'A Message'; + +$outFile = "mailBasic.out"; +@unlink($outFile); + +var_dump( mail($to, $subject, $message, '') ); +echo file_get_contents($outFile); +unlink($outFile); + +?> +===DONE=== +--EXPECTF-- +*** Testing mail() : send email without additional headers *** +bool(true) +To: user@company.com +Subject: Test Subject +X-PHP-Originating-Script: %d:bug69874_2.php + +A Message +===DONE=== |