mirror of
https://github.com/php/php-src.git
synced 2024-11-24 10:24:11 +08:00
Merge branch 'PHP-7.3'
* PHP-7.3: Fix #66828: iconv_mime_encode Q-encoding longer than it should be
This commit is contained in:
commit
7022f3a34f
@ -1354,7 +1354,7 @@ static php_iconv_err_t _php_iconv_mime_encode(smart_str *pretval, const char *fn
|
||||
prev_in_left = ini_in_left = in_left;
|
||||
ini_in_p = in_p;
|
||||
|
||||
for (out_size = (char_cnt - 2) / 3; out_size > 0;) {
|
||||
for (out_size = (char_cnt - 2); out_size > 0;) {
|
||||
#if !ICONV_SUPPORTS_ERRNO
|
||||
size_t prev_out_left;
|
||||
#endif
|
||||
@ -1418,7 +1418,7 @@ static php_iconv_err_t _php_iconv_mime_encode(smart_str *pretval, const char *fn
|
||||
break;
|
||||
}
|
||||
|
||||
out_size -= ((nbytes_required - (char_cnt - 2)) + 1) / 3;
|
||||
out_size -= ((nbytes_required - (char_cnt - 2)) + 2) / 3;
|
||||
in_left = ini_in_left;
|
||||
in_p = ini_in_p;
|
||||
}
|
||||
|
@ -5,18 +5,17 @@ Bug #53891 (iconv_mime_encode() fails to Q-encode UTF-8 string)
|
||||
if (!extension_loaded('iconv')) die('skip iconv extension not available');
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
$preferences = array(
|
||||
'scheme' => 'Q',
|
||||
'input-charset' => 'utf-8',
|
||||
'output-charset' => 'utf-8',
|
||||
'line-length' => 74,
|
||||
'line-break-chars' => "\r\n",
|
||||
);
|
||||
var_dump(iconv_mime_encode('subject', "d obeybiubrsfqllpdtpge…", $preferences));
|
||||
<?php
|
||||
$preferences = array(
|
||||
'scheme' => 'Q',
|
||||
'input-charset' => 'utf-8',
|
||||
'output-charset' => 'utf-8',
|
||||
'line-length' => 74,
|
||||
'line-break-chars' => "\r\n",
|
||||
);
|
||||
var_dump(iconv_mime_encode('subject', "d obeybiubrsfqllpdtpge…", $preferences));
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECT--
|
||||
string(81) "subject: =?utf-8?Q?d=20obeybiubrsfqllp?==?utf-8?Q?dtpge?=
|
||||
=?utf-8?Q?=E2=80=A6?="
|
||||
string(54) "subject: =?utf-8?Q?d=20obeybiubrsfqllpdtpge=E2=80=A6?="
|
||||
===DONE===
|
||||
|
21
ext/iconv/tests/bug66828.phpt
Normal file
21
ext/iconv/tests/bug66828.phpt
Normal file
@ -0,0 +1,21 @@
|
||||
--TEST--
|
||||
Bug #66828 (iconv_mime_encode Q-encoding longer than it should be)
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('iconv')) die('skip iconv extension not available');
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
$preferences = array(
|
||||
"input-charset" => "ISO-8859-1",
|
||||
"output-charset" => "UTF-8",
|
||||
"line-length" => 76,
|
||||
"line-break-chars" => "\n",
|
||||
"scheme" => "Q"
|
||||
);
|
||||
var_dump(iconv_mime_encode("Subject", "Test Test Test Test Test Test Test Test", $preferences));
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECT--
|
||||
string(74) "Subject: =?UTF-8?Q?Test=20Test=20Test=20Test=20Test=20Test=20Test=20Test?="
|
||||
===DONE===
|
Loading…
Reference in New Issue
Block a user