Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ext/standard/quot_print.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ PHPAPI zend_string *php_quot_print_encode(const unsigned char *str, size_t lengt
lp = 0;
} else {
if (iscntrl (c) || (c == 0x7f) || (c & 0x80) || (c == '=') || ((c == ' ') && (*str == '\015'))) {
if ((((lp+= 3) > PHP_QPRINT_MAXL) && (c <= 0x7f))
if ((((lp+= 3) > PHP_QPRINT_MAXL) && ((c <= 0x7f) || (c > 0xf4)))
|| ((c > 0x7f) && (c <= 0xdf) && ((lp + 3) > PHP_QPRINT_MAXL))
|| ((c > 0xdf) && (c <= 0xef) && ((lp + 6) > PHP_QPRINT_MAXL))
|| ((c > 0xef) && (c <= 0xf4) && ((lp + 9) > PHP_QPRINT_MAXL))) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
--TEST--
quoted_printable_encode() keeps lines within 76 characters for bytes 0xF5 to 0xFF
--FILE--
<?php

foreach (["\xF5", "\xF8", "\xFF"] as $byte) {
$str = str_repeat($byte, 30);
$encoded = quoted_printable_encode($str);
echo bin2hex($byte), ": ", implode(",", array_map('strlen', explode("\r\n", $encoded))), "\n";
var_dump(quoted_printable_decode($encoded) === $str);
}

?>
--EXPECT--
f5: 76,15
bool(true)
f8: 76,15
bool(true)
ff: 76,15
bool(true)
Loading