1
0
mirror of https://github.com/php/php-src.git synced 2026-03-28 02:02:32 +01:00

Merge branch 'PHP-8.2'

* PHP-8.2:
  Fix regression test for GH-9535 on PHP-8.2+
This commit is contained in:
Alex Dowad
2022-11-14 11:47:06 +02:00
2 changed files with 24 additions and 39 deletions

View File

@@ -147,6 +147,9 @@ int mbfl_filt_conv_utf7imap_wchar(int c, mbfl_convert_filter *filter)
* or it could be that it ended on the first half of a surrogate pair */
filter->cache = filter->status = 0;
CK((*filter->output_function)(MBFL_BAD_INPUT, filter->data));
} else {
/* Base64-encoded section properly terminated by - */
filter->cache = filter->status = 0;
}
} else { /* illegal character */
filter->cache = filter->status = 0;

View File

@@ -5,9 +5,6 @@ mbstring
--FILE--
<?php
$encodings = [
'BASE64',
'HTML-ENTITIES',
'Quoted-Printable',
'UTF-16',
'UTF-16BE',
'UTF-16LE',
@@ -58,6 +55,8 @@ echo PHP_EOL;
$input = 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA';
$bytes_length = 10;
// For ISO-2022-KR, the initial escape sequence 'ESC $ ) C' will occupy 4 bytes of the output;
// this will make mb_strcut only pick out 6 'A' characters from the input string and not 10
foreach($encodings as $encoding) {
$converted_str = mb_convert_encoding($input, $encoding, mb_internal_encoding());
$cut_str = mb_strcut($converted_str, 0, $bytes_length, $encoding);
@@ -69,24 +68,22 @@ echo PHP_EOL;
$input = '???';
$bytes_length = 2;
// ISO-2022-KR will be affected by the initial escape sequence as stated above
foreach($encodings as $encoding) {
$converted_str = mb_convert_encoding($input, $encoding, mb_internal_encoding());
$cut_str = mb_strcut($converted_str, 0, $bytes_length, $encoding);
$reconverted_str = mb_convert_encoding($cut_str, mb_internal_encoding(), $encoding);
echo $encoding.': '.$reconverted_str.PHP_EOL;
echo $encoding.trim(': '.$reconverted_str).PHP_EOL;
}
echo PHP_EOL;
foreach($encodings as $encoding) {
var_dump(mb_strcut($input, 0, $bytes_length, $encoding));
echo $encoding.trim(': '.mb_strcut($input, 0, $bytes_length, $encoding)).PHP_EOL;
}
?>
--EXPECTF--
BASE64: 宛如繁
HTML-ENTITIES: 宛&#22914
Quoted-Printable: %s
--EXPECT--
UTF-16: 宛如繁星般宛如
UTF-16BE: 宛如繁星般宛如
UTF-16LE: 宛如繁星般宛如
@@ -101,9 +98,6 @@ CP50220: 宛如繁星
CP50221: 宛如繁星
CP50222: 宛如繁星
BASE64: 星のように
HTML-ENTITIES: 星の&#12
Quoted-Printable: 星の
UTF-16: 星のように月のように
UTF-16BE: 星のように月のように
UTF-16LE: 星のように月のように
@@ -118,9 +112,6 @@ CP50220: 星のように月の
CP50221: 星のように月の
CP50222: 星のように月の
BASE64: %s
HTML-ENTITIES: あa&
Quoted-Printable: あa
UTF-16: あaいb
UTF-16BE: あaいb
UTF-16LE: あaいb
@@ -135,9 +126,6 @@ CP50220: あa
CP50221: あa
CP50222: あa
BASE64: AAAAAA
HTML-ENTITIES: AAAAAAAAAA
Quoted-Printable: AAAAAAAAAA
UTF-16: AAAAA
UTF-16BE: AAAAA
UTF-16LE: AAAAA
@@ -146,15 +134,12 @@ UTF7-IMAP: AAAAAAAAAA
ISO-2022-JP-MS: AAAAAAAAAA
GB18030: AAAAAAAAAA
HZ: AAAAAAAAAA
ISO-2022-KR: AAAAAAAAAA
ISO-2022-KR: AAAAAA
ISO-2022-JP-MOBILE#KDDI: AAAAAAAAAA
CP50220: AAAAAAAAAA
CP50221: AAAAAAAAAA
CP50222: AAAAAAAAAA
BASE64:%s
HTML-ENTITIES: ??
Quoted-Printable: ??
UTF-16: ?
UTF-16BE: ?
UTF-16LE: ?
@@ -163,25 +148,22 @@ UTF7-IMAP: ??
ISO-2022-JP-MS: ??
GB18030: ??
HZ: ??
ISO-2022-KR: ??
ISO-2022-KR:
ISO-2022-JP-MOBILE#KDDI: ??
CP50220: ??
CP50221: ??
CP50222: ??
string(0) ""
string(2) "??"
string(2) "??"
string(2) "??"
string(2) "??"
string(2) "??"
string(2) "??"
string(2) "??"
string(2) "??"
string(2) "??"
string(2) "??"
string(2) "??"
string(2) "??"
string(2) "??"
string(2) "??"
string(2) "??"
UTF-16: ??
UTF-16BE: ??
UTF-16LE: ??
UTF-7: ??
UTF7-IMAP: ??
ISO-2022-JP-MS: ??
GB18030: ??
HZ: ??
ISO-2022-KR:
ISO-2022-JP-MOBILE#KDDI: ??
CP50220: ??
CP50221: ??
CP50222: ??