Bug #72964 [Com]: White space not unfolded for CC/Bcc headers

From: Date: Wed, 03 Feb 2021 15:13:35 +0000
Subject: Bug #72964 [Com]: White space not unfolded for CC/Bcc headers
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-231915@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=72964&edit=1

 ID:                 72964
 Comment by:         josh at dirxion dot com
 Reported by:        hynek dot petrak at gmail dot com
 Summary:            White space not unfolded for CC/Bcc headers
 Status:             Closed
 Type:               Bug
 Package:            Mail related
 Operating System:   Windows
 PHP Version:        5.6.25
 Assigned To:        cmb
 Block user comment: N
 Private report:     N

 New Comment:

With the release of PHP 7.4.14 we are experiencing an issue with our web email forms being
processed. It seems to mangle the HTML formatting when there is only one email address. I have
verified the problem does not exists in version 7.4.13 and that if I provide multiple addresses the
mangled HTML email content problem goes away. 

This is an example of what we have going on and generates the broken HTML formatting. 

'Bcc: '. $VariableEmailGroup . "\r\n" .

If we add on a 2nd email address to the same syntax, the HTML formatting of the email is preserved
properly. The problem is we don't want to list out multiple email addresses. 

'Bcc: ' . $VariableEmailGroup . ", \r\n\tuseremail@thisworksok.com\r\n" .

If you need further details I can nudge our developers, but they suspect this bug patch broke our
email formatting.


Previous Comments:
------------------------------------------------------------------------
[2020-11-19 18:27:43] cmb@php.net

Automatic comment on behalf of cmbecker69@gmx.de
Revision: http://git.php.net/?p=php-src.git;a=commit;h=881e43a03c774bf8d31b5fe751bd493447174ad0
Log: Fix #72964: White space not unfolded for CC/Bcc headers

------------------------------------------------------------------------
[2020-11-10 15:31:24] cmb@php.net

The following pull request has been associated:

Patch Name: Fix #72964: White space not unfolded for CC/Bcc headers
On GitHub:  https://github.com/php/php-src/pull/6420
Patch:      https://github.com/php/php-src/pull/6420.patch

------------------------------------------------------------------------
[2016-08-29 12:40:55] hynek dot petrak at gmail dot com

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 this bug report at https://bugs.php.net/bug.php?id=72964&edit=1


Thread (6 messages)

« previous php.bugs (#231915) next »