diff --git a/ext/standard/quot_print.c b/ext/standard/quot_print.c index 75606c44a980..0fc8c27343c9 100644 --- a/ext/standard/quot_print.c +++ b/ext/standard/quot_print.c @@ -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))) { diff --git a/ext/standard/tests/strings/quoted_printable_encode_line_length.phpt b/ext/standard/tests/strings/quoted_printable_encode_line_length.phpt new file mode 100644 index 000000000000..b7cd09b52a64 --- /dev/null +++ b/ext/standard/tests/strings/quoted_printable_encode_line_length.phpt @@ -0,0 +1,20 @@ +--TEST-- +quoted_printable_encode() keeps lines within 76 characters for bytes 0xF5 to 0xFF +--FILE-- + +--EXPECT-- +f5: 76,15 +bool(true) +f8: 76,15 +bool(true) +ff: 76,15 +bool(true)