Skip to content

Fix quoted_printable_encode() exceeding the line length for bytes 0xF5 to 0xFF - #24442

Open
auraseb wants to merge 1 commit into
php:PHP-8.4from
auraseb:fix/quoted-printable-encode-long-lines
Open

auraseb wants to merge 1 commit into
php:PHP-8.4from
auraseb:fix/quoted-printable-encode-long-lines

Conversation

@auraseb

@auraseb auraseb commented Oct 19, 2026

Copy link
Copy Markdown

php_quot_print_encode() decides whether to insert a soft line break based on the byte being encoded. Bytes up to 0x7F and the UTF-8 lead and continuation bytes up to 0xF4 are covered, but bytes 0xF5 to 0xFF match no branch, so they never cause a break. A run of such bytes (or binary data that ends a line with one) produces lines longer than the 76 characters RFC 2045 allows:

var_dump(strlen(quoted_printable_encode(str_repeat("\xFF", 30)))); // one 90 character line

These bytes can not start a UTF-8 sequence, so this treats them like single bytes and breaks as soon as the encoded byte no longer fits on the line.

The decoded output is unchanged; only the placement of soft line breaks differs. Added a test covering 0xF5, 0xF8 and 0xFF.

Targets the lowest supported bugfix branch; the patch applies unchanged there.

Fixes #24441

…5 to 0xFF

Signed-off-by: Sebastian Turner <sebastiant3484@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant