Bug #72964 [NEW]: White space not unfolded for CC/Bcc headers
From: hynek dot petrak at gmail dot com
Operating system: Windows
PHP version: 5.6.25
Package: Mail related
Bug Type: Bug
Bug description:White space not unfolded for CC/Bcc headers
Description:
------------
According to RFC2822 / 2.2.3. Long Header Fields, each header field can
use White space folding. E.g.:
To: xy@example.com\r\n
CC: ab@example.com,\r\n
cd@example.com\r\n
Subject: subject text
In the win32/sendmail.c SendText() function, the cc: and bcc: headers
are considered only up to the next \r\n, ignoring any additional folded
lines. This occures on Windows when "sendmail_path" is not defined in
php.ini.
Problematic code:
pos1 = headers + (pos1 - headers_lc) + 3;
if (NULL == (pos2 = strstr(pos1, "\r\n"))) {
tempMailTo = estrndup(pos1, strlen(pos1));
} else {
tempMailTo = estrndup(pos1, pos2 - pos1);
}
IMHO any folding sequence "\r\n\t" or "\r\n " shall be replaced with
"\t" or " " in header_lc before scanning. Other solutions might be
convenient too.
Test script:
---------------
<?php
$to = 'nobody@example.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: webmaster@example.com' . "\r\n" .
'Cc: cc1@example.com' . "\r\n" . ', ' .
'\tcc2@example.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
?>
Expected result:
----------------
cc2@example.com shall receive an email.
Actual result:
--------------
cc2@example.com does not receive an email. in the SMTP protocol RCPT TO:
cc2@example.com is missing.
--
Edit bug report at https://bugs.php.net/bug.php?id=72964&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=72964&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=72964&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=72964&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=72964&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=72964&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=72964&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=72964&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=72964&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=72964&r=support
Expected behavior: https://bugs.php.net/fix.php?id=72964&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=72964&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=72964&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=72964&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=72964&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=72964&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=72964&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=72964&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=72964&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=72964&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=72964&r=mysqlcfg
Thread (6 messages)
- hynek dot petrak at gmail dot com