com php-src: [bug 66535] X-PHP-Originating-Script adds newline if no custom headers are given: ext/standard/mail.c
ext/standard/tests/mail/bug66535.phpt
| From: | Tjerk Anne Meesters | Date: | Fri, 28 Feb 2014 14:22:07 +0000 |
| Subject: | com php-src: [bug 66535] X-PHP-Originating-Script adds newline if no custom headers are given: ext/standard/mail.c ext/standard/tests/mail/bug66535.phpt |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-76276@lists.php.net to get a copy of this message | ||
Commit: 79b3c2a744e68c61ccfe36df097bdbdfe6e7ff48
Author: Tjerk Meesters <datibbaw@php.net> Fri, 28 Feb 2014 22:22:07 +0800
Parents: b1df743b7a9da1b84d5af8dfb430a98022009cd8
Branches: PHP-5.4 PHP-5.5 PHP-5.6 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=79b3c2a744e68c61ccfe36df097bdbdfe6e7ff48
Log:
[bug 66535] X-PHP-Originating-Script adds newline if no custom headers are given
A newline is added to the mail headers when mail.add_x_header is used and no other headers are
passed to mail().
The scenario in which custom headers are used was already fixed in #48620, back in 2009.
Bugs:
https://bugs.php.net/66535
https://bugs.php.net/48620
Changed paths:
M ext/standard/mail.c
A ext/standard/tests/mail/bug66535.phpt
Diff:
diff --git a/ext/standard/mail.c b/ext/standard/mail.c
index 43adfee..1ebc8fe 100644
--- a/ext/standard/mail.c
+++ b/ext/standard/mail.c
@@ -276,7 +276,7 @@ PHPAPI int php_mail(char *to, char *subject, char *message, char *headers, char
if (headers != NULL) {
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\n", php_getuid(TSRMLS_C), f);
+ spprintf(&hdr, 0, "X-PHP-Originating-Script: %ld:%s", php_getuid(TSRMLS_C), f);
}
efree(f);
}
diff --git a/ext/standard/tests/mail/bug66535.phpt b/ext/standard/tests/mail/bug66535.phpt
new file mode 100644
index 0000000..75e1284
--- /dev/null
+++ b/ext/standard/tests/mail/bug66535.phpt
@@ -0,0 +1,43 @@
+--TEST--
+Test mail() function : basic functionality
+--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:bug66535.php
+
+A Message
+===DONE===