quoted_printable_encode() produces lines longer than 76 characters for bytes 0xF5 to 0xFF
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 76/100
Research direction
Start with php_quot_print_encode() in ext/standard/quot_print.c and compare its soft-break handling for bytes 0xF5 to 0xFF with the existing branches. Check the relevant quoted-printable tests and add coverage for a run of these bytes. Done means encoded lines stay within the RFC 2045 limit of 76 characters; the issue reports that the stream filter is unaffected.
Written by the indexing model from the issue text.
Description
Description
quoted_printable_encode() is documented to follow RFC 2045 section 6.7, which limits encoded lines to 76 characters. Input bytes in the range 0xF5 to 0xFF are encoded as =XX but never trigger a soft line break, so a run of them ends up on a single line of any length.
The following code:
<?php
$encoded = quoted_printable_encode(str_repeat("\xFF", 30));
var_dump(array_map('strlen', explode("\r\n", $encoded)));
Resulted in this output:
array(1) {
[0]=>
int(90)
}
But I expected this output instead:
array(2) {
[0]=>
int(76)
[1]=>
int(15)
}
The same happens with any binary data that contains such bytes, for example a random string of a few hundred bytes regularly produces 78 or 79 character lines. The convert.quoted-printable-encode stream filter is not affected.
Root cause: in php_quot_print_encode() (ext/standard/quot_print.c) the soft break condition has one branch for bytes up to 0x7F and three branches for UTF-8 lead and continuation bytes (0x80 to 0xDF, 0xE0 to 0xEF, 0xF0 to 0xF4). Bytes 0xF5 to 0xFF match none of them, so the line position keeps growing without a break being inserted.
PHP Version
PHP 8.7.0-dev (master at b7256eee), also present in all supported branches
Operating System
Any
- Dominant language
- C
- Stars
- 40.7k
- Forks
- 8.3k
- Avg merge
- 2d 15h
- Merged PRs (30d)
- 155
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from php/php-src
-
Case-insensitive substr_compare, ksort, krsort are still locale-dependentPossibly taken A pull request linked to this issue is open or already merged. OpenBug Status: Needs Triage
Difficulty 2/5 1-3 hours Newbie friendliness 73/100
php/php-src#24552 · 1 comment ·
Maintainers usually reply within 1 day
-
Bug Status: Needs Triage
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Bug Status: Needs Triage
Difficulty 2/5 1-3 hours Newbie friendliness 71/100
php/php-src#24505 · 2 comments ·
Maintainers usually reply within 1 day
-
master: part of the mbstring bailout fix got lost in a mergePossibly taken @lazerg claimed this 1 day ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Bug Status: Needs Triage
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
Maintainers usually reply within 1 day
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
Difficulty 1/5 Under an hour Newbie friendliness 93/100
webarkit/WebARKitLib#107 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
polhenarejos/pico-fido#302 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
espressif/esp-vision#16 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
libsdl-org/SDL#16577 ·
Maintainers usually reply within 1 day