[php-src] Issue #24458: quoted_printable_encode does not encode trailing space

From: Date: Tue, 20 Oct 2026 09:44:55 +0000
Subject: [php-src] Issue #24458: quoted_printable_encode does not encode trailing space
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-253046@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/24458 Author: Sjord ### Description The following code: ```php <?php var_dump(quoted_printable_encode('hello ')); ``` Resulted in this output: ``` string(6) "hello " ``` But I expected this output instead: ``` string(9) "hello=20" ``` RFC 2045 says: > (3) (White Space) Octets with values of 9 and 32 MAY be > represented as US-ASCII TAB (HT) and SPACE characters, > respectively, but MUST NOT be so represented at the end > of an encoded line. Any TAB (HT) or SPACE characters > on an encoded line MUST thus be followed on that line > by a printable character. In particular, an "=" at the > end of an encoded line, indicating a soft line break > (see rule #5) may follow one or more TAB (HT) or SPACE > characters. It follows that an octet with decimal > value 9 or 32 appearing at the end of an encoded line > must be represented according to Rule #1. This rule is > necessary because some MTAs (Message Transport Agents, > programs which transport messages from one user to > another, or perform a portion of such transfers) are > known to pad lines of text with SPACEs, and others are > known to remove "white space" characters from the end > of a line. Therefore, when decoding a Quoted-Printable > body, any trailing white space on a line must be > deleted, as it will necessarily have been added by > intermediate transport agents. ### PHP Version ```plain PHP 8.7.0-dev (cli) (built: Oct 18 2026 16:29:33) (NTS DEBUG) Copyright © The PHP Group and Contributors Zend Engine v4.7.0-dev, Copyright © Zend by Perforce with Zend OPcache v8.7.0-dev, Copyright ©, by Zend by Perforce ``` ### Operating System _No response_

« previous php.bugs (#253046) next »