com php-src: Bug 62462: Prevent multibyte characters from being split between the lines: ext/standard/quot_print.c ext/standard
/tests/strings/bug62462.phpt
| From: | Lars Strojny | Date: | Mon, 20 Aug 2012 21:46:50 +0000 |
| Subject: | com php-src: Bug 62462: Prevent multibyte characters from being split between the lines: ext/standard/quot_print.c ext/standard /tests/strings/bug62462.phpt |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-69897@lists.php.net to get a copy of this message | ||
Commit: c54d73d54c8e2166f680b3db03238d5263a451c1
Author: Lars Strojny <lstrojny@php.net> Mon, 20 Aug 2012 23:42:31 +0200
Parents: cc5631eca3e9aac195493a0edb7a730f3bc82a65
Branches: PHP-5.4
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=c54d73d54c8e2166f680b3db03238d5263a451c1
Log:
Bug 62462: Prevent multibyte characters from being split between the lines
Merged from https://github.com/php/php-src/pull/120
Bugs:
https://bugs.php.net/62462
Changed paths:
M ext/standard/quot_print.c
A ext/standard/tests/strings/bug62462.phpt
Diff:
diff --git a/ext/standard/quot_print.c b/ext/standard/quot_print.c
index 1ce7eff..4eb69d7 100644
--- a/ext/standard/quot_print.c
+++ b/ext/standard/quot_print.c
@@ -162,7 +162,10 @@ PHPAPI unsigned char *php_quot_print_encode(const unsigned char *str, size_t
len
lp = 0;
} else {
if (iscntrl (c) || (c == 0x7f) || (c & 0x80) || (c == '=') || ((c == '
') && (*str == '\015'))) {
- if ((lp += 3) > PHP_QPRINT_MAXL) {
+ if ((((lp+= 3) > PHP_QPRINT_MAXL) && (c <= 0x7f))
+ || ((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))) {
*d++ = '=';
*d++ = '\015';
*d++ = '\012';
@@ -283,4 +286,4 @@ PHP_FUNCTION(quoted_printable_encode)
* End:
* vim600: sw=4 ts=4 fdm=marker
* vim<600: sw=4 ts=4
- */
+ */
\ No newline at end of file
diff --git a/ext/standard/tests/strings/bug62462.phpt b/ext/standard/tests/strings/bug62462.phpt
new file mode 100644
index 0000000..c6eb41a
--- /dev/null
+++ b/ext/standard/tests/strings/bug62462.phpt
@@ -0,0 +1,17 @@
+--TEST--
+Multibyte characters shouldn't be split by soft line break added by quoted_printable_encode -
4 byte character test
+--FILE--
+<?php
+echo quoted_printable_encode(str_repeat("\xc4\x85", 77));
+?>
+
+==DONE==
+--EXPECT--
+=C4=85=C4=85=C4=85=C4=85=C4=85=C4=85=C4=85=C4=85=C4=85=C4=85=C4=85=C4=85=
+=C4=85=C4=85=C4=85=C4=85=C4=85=C4=85=C4=85=C4=85=C4=85=C4=85=C4=85=C4=85=
+=C4=85=C4=85=C4=85=C4=85=C4=85=C4=85=C4=85=C4=85=C4=85=C4=85=C4=85=C4=85=
+=C4=85=C4=85=C4=85=C4=85=C4=85=C4=85=C4=85=C4=85=C4=85=C4=85=C4=85=C4=85=
+=C4=85=C4=85=C4=85=C4=85=C4=85=C4=85=C4=85=C4=85=C4=85=C4=85=C4=85=C4=85=
+=C4=85=C4=85=C4=85=C4=85=C4=85=C4=85=C4=85=C4=85=C4=85=C4=85=C4=85=C4=85=
+=C4=85=C4=85=C4=85=C4=85=C4=85
+==DONE==