[php-src] PR #24463: Fix convert.quoted-printable-encode losing or duplicating a partial line break
| From: | auraseb | Date: | Tue, 20 Oct 2026 15:32:35 +0000 |
| Subject: | [php-src] PR #24463: Fix convert.quoted-printable-encode losing or duplicating a partial line break | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-39639@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/24463
Author: auraseb
When
line-break-chars is set, php_conv_qprint_encode_convert() holds back
characters that may start a line break sequence. If a write ended in the middle of such a sequence:
* the converter started emitting the held back characters as encoded bytes but kept them counted in
lb_cnt, so when the next write completed the sequence the line break was emitted again
("Hello=\r" followed by "\nWorld" decodes to
"Hello=\r\r\nWorld");
* if the output buffer was full at that point, the characters stayed pending, and the flush on close
returned early without writing them ("a\r" encodes to
"a").
This change keeps a partial line break pending at the end of the input until more data arrives, and
emits it on the final flush (NULL input), which the converter previously ignored. The trailing
whitespace lookahead is skipped when no input is left so it never reads from the NULL input pointer
during the flush.
Output for input that does not end in a partial line break is unchanged. Added a test with single
and split writes; every case now decodes back to the original data.
Fixes #24462