[php-src] Issue #14084: mail() breaks quoted_printable_encode()d subject

From: Date: Tue, 30 Apr 2024 13:48:23 +0000
Subject: [php-src] Issue #14084: mail() breaks quoted_printable_encode()d subject
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-246840@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/14084 Author: hornschorsch ### Description The following code: ``` $subject = "=?$charset?Q?" . quoted_printable_encode("Onlinetreffen $thema $datum $zeit") . "?="; [...] mail("$mailname <$email>", $subject, $mailtext, $headers, "-f $mailfrom"); ``` Resulted in an email with this header: ``` Subject: =?iso-8859-1?Q?Onlinetreffen Starke Leistungen - fairer Beitrag: Das sollten ver.di Mitgli= eder unbedingt wissen 14.05.2024 17:00:00?= ``` But I expected this header instead: ``` Subject: =?iso-8859-1?Q?Onlinetreffen Starke Leistungen - fairer Beitrag: Das sollten ver.di Mitgli= eder unbedingt wissen 14.05.2024 17:00:00?= ``` This happens because quoted_printable_encode() wraps lines at 75 characters and therefore inserts a "=\r\n" but the mail() function replaces every control character, that is not a \r followed by \n followed by space, with a space. So quoted_printable_encode() should insert an additional space to prevent mail() from replacing the \r\n with spaces or the check in mail() should not check for a space after "\r\n" but for a "=" before the "\r\n" https://github.com/php/php-src/blob/master/ext/standard/quot_print.c#L175 https://github.com/php/php-src/blob/master/ext/standard/mail.c#L307 https://github.com/php/php-src/blob/master/ext/standard/mail.c#L49 ### PHP Version current version, see links to sourcecode ### Operating System _No response_

« previous php.bugs (#246840) next »