Skip to content

Commit d4d726b

Browse files
committed
Merge branch 'PHP-5.6'
* PHP-5.6: Fixed test case title [bug 66535] X-PHP-Originating-Script adds newline if no custom headers are given
2 parents 060643f + 43ac0ab commit d4d726b

File tree

2 files changed

+44
-1
lines changed

2 files changed

+44
-1
lines changed

ext/standard/mail.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ PHPAPI int php_mail(char *to, char *subject, char *message, char *headers, char
286286
if (headers != NULL) {
287287
spprintf(&hdr, 0, "X-PHP-Originating-Script: %ld:%s\n%s", php_getuid(TSRMLS_C), f, headers);
288288
} else {
289-
spprintf(&hdr, 0, "X-PHP-Originating-Script: %ld:%s\n", php_getuid(TSRMLS_C), f);
289+
spprintf(&hdr, 0, "X-PHP-Originating-Script: %ld:%s", php_getuid(TSRMLS_C), f);
290290
}
291291
efree(f);
292292
}

ext/standard/tests/mail/bug66535.phpt

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
--TEST--
2+
Bug #66535: Extra newline if add_x_header and no additional headers are used
3+
--INI--
4+
sendmail_path=tee mailBasic.out >/dev/null
5+
mail.add_x_header = On
6+
--SKIPIF--
7+
<?php
8+
if(substr(PHP_OS, 0, 3) == "WIN")
9+
die("skip Won't run on Windows");
10+
?>
11+
--FILE--
12+
<?php
13+
/* Prototype : int mail(string to, string subject, string message [, string additional_headers [, string additional_parameters]])
14+
* Description: Send an email message
15+
* Source code: ext/standard/mail.c
16+
* Alias to functions:
17+
*/
18+
19+
echo "*** Testing mail() : send email without additional headers ***\n";
20+
21+
// Initialise all required variables
22+
23+
$subject = 'Test Subject';
24+
$message = 'A Message';
25+
26+
$outFile = "mailBasic.out";
27+
@unlink($outFile);
28+
29+
var_dump( mail($to, $subject, $message) );
30+
echo file_get_contents($outFile);
31+
unlink($outFile);
32+
33+
?>
34+
===DONE===
35+
--EXPECTF--
36+
*** Testing mail() : send email without additional headers ***
37+
bool(true)
38+
39+
Subject: Test Subject
40+
X-PHP-Originating-Script: %d:bug66535.php
41+
42+
A Message
43+
===DONE===

0 commit comments

Comments
 (0)