php-src/ext
NathanFreeman fa0401b0b5 Fix GH-9535 (unintended behavior change for mb_strcut in PHP 8.1)
The existing implementation of mb_strcut extracts part of a
multi-byte encoded string by pulling out raw bytes and then running
them through a conversion filter to ensure that the output is valid
in the requested encoding.

If the conversion filter emits error markers when doing the final
'flush' operation which ends the conversion of the extracted bytes,
these error markers may (in some cases) be included in the output.
The conversion operation does not respect the value of
mb_substitute_character; rather, it always uses '?' as an error marker.
So this issue manifests itself as unwanted '?' characters being
inserted into the output.

This issue has existed for a long time, but became noticeable in PHP
8.1 because for at least some of the supported text encodings, mbstring
is now more strict about emitting error markers when strings end in an
illegal state.

The simplest fix is to suppress error markers during the final flush
operation.

While working on a fix for this problem, another problem with mb_strcut
was discovered; since it decides when to stop consuming bytes from
the input by looking at the byte length of its OUTPUT, anything which
causes extra bytes to be emitted to the output may cause mb_strcut to
not consume all the bytes in the requested range.

The one case where we DO emit extra output bytes is for encodings
which have a selectable mode, like ISO-2022-JP; if a string in such
an encoding ends in a mode which is not the default, we emit an ending
escape sequence which changes back to the default mode. This is done
so that concatenating strings in such encodings is safe.

However, as mentioned, this can cause the output of mb_strcut to be
shorter than it logically should be. This bug has existed for a long
time, and fixing it now will be a BC break, so we may not fix it right
away.

Therefore, tests for THIS fix which don't pass because of that OTHER
bug have been split out into a separate test file (gh9535b.phpt), and
that file has been marked XFAIL.
2022-11-13 14:37:55 +02:00
..
bcmath
bz2 Merge branch 'PHP-8.0' into PHP-8.1 2022-06-25 07:39:55 +01:00
calendar Add more specific array return type hints for various extensions - part 1 2021-11-07 08:46:25 +01:00
com_dotnet Merge branch 'PHP-8.0' into PHP-8.1 2022-06-18 11:50:14 +02:00
ctype
curl Merge branch 'PHP-8.0' into PHP-8.1 2022-06-17 19:52:44 -04:00
date Updated to version 2022.6 (2022f) 2022-11-02 09:43:39 +00:00
dba Merge branch 'PHP-8.0' into PHP-8.1 2022-07-27 12:13:32 +02:00
dl_test Fix unregistering ini entries of dynamically loaded extension (#8435) 2022-05-06 15:25:44 +02:00
dom Add missing EXTENSION section to tests 2022-10-27 14:39:43 +01:00
enchant Add more specific array return type hints for various extensions - part 1 2021-11-07 08:46:25 +01:00
exif Fix GH-8408: bug68547.phpt fails without multibyte support 2022-04-20 16:42:09 +02:00
ffi Merge branch 'PHP-8.0' into PHP-8.1 2022-11-03 14:37:17 +01:00
fileinfo fileinfo: tests: Disable times sensitive tests on debug build 2022-09-25 20:43:31 +02:00
filter Add missing EXTENSION section to tests 2022-10-27 14:39:43 +01:00
ftp Add more specific array return type hints for various extensions - part 2 2021-11-17 10:56:27 +01:00
gd Update new test to use EXTENSIONS section instead of SKIPIF 2022-10-24 15:02:05 +02:00
gettext
gmp Merge branch 'PHP-8.0' into PHP-8.1 2022-09-13 11:33:09 +01:00
hash Merge branch 'PHP-8.0' into PHP-8.1 2022-10-21 00:05:30 -06:00
iconv Merge branch 'PHP-8.0' into PHP-8.1 2022-04-25 14:29:44 +02:00
imap Fix GH-9309: Segfault when connection is used after imap_close() 2022-08-12 16:24:30 +02:00
intl Merge branch 'PHP-8.0' into PHP-8.1 2022-09-13 12:45:42 +01:00
json Register JSON_ERROR_NON_BACKED_ENUM constant (#8285) 2022-03-31 14:31:17 +02:00
ldap
libxml Merge branch 'PHP-8.0' into PHP-8.1 2022-08-25 15:11:41 +02:00
mbstring Fix GH-9535 (unintended behavior change for mb_strcut in PHP 8.1) 2022-11-13 14:37:55 +02:00
mysqli Merge branch 'PHP-8.0' into PHP-8.1 2022-10-27 18:31:38 +01:00
mysqlnd Merge branch 'PHP-8.0' into PHP-8.1 2022-10-27 18:31:38 +01:00
oci8 Skip some OCI tests with repeat 2022-09-27 23:32:15 +02:00
odbc Merge branch 'PHP-8.0' into PHP-8.1 2022-06-13 14:43:51 +02:00
opcache Fix memory leak 2022-11-07 11:07:58 +03:00
openssl Add missing EXTENSION section to tests 2022-10-27 14:39:43 +01:00
pcntl Fix GH-9298: remove all registered signal handlers in pcntl RSHUTDOWN 2022-11-13 10:57:58 +01:00
pcre Fix pcre.jit on Apple Silicon 2022-08-31 14:22:44 +02:00
pdo Fix pdo_oci tests for PHP 8.1 2022-08-24 14:39:45 +02:00
pdo_dblib Merge branch 'PHP-8.0' into PHP-8.1 2022-08-26 14:59:08 +02:00
pdo_firebird Fix #76452: Crash while parsing blob data in firebird_fetch_blob 2022-06-07 09:59:17 -05:00
pdo_mysql Merge branch 'PHP-8.0' into PHP-8.1 2022-05-03 12:43:14 +02:00
pdo_oci [skip ci] Backport XFAIL of failing test 2022-11-11 19:46:16 +01:00
pdo_odbc Merge branch 'PHP-8.0' into PHP-8.1 2022-06-13 14:43:51 +02:00
pdo_pgsql Merge branch 'PHP-8.0' into PHP-8.1 2022-09-05 17:26:13 +02:00
pdo_sqlite Merge branch 'PHP-8.0' into PHP-8.1 2022-07-27 13:06:15 +02:00
pgsql Add missing EXTENSIONS section to new test 2022-06-06 12:21:25 +02:00
phar Merge branch 'PHP-8.0' into PHP-8.1 2022-09-27 18:45:54 +02:00
posix
pspell
readline
reflection Merge branch 'PHP-8.0' into PHP-8.1 2022-09-08 10:44:13 +02:00
session Merge branch 'PHP-8.0' into PHP-8.1 2022-10-06 14:29:53 +01:00
shmop
simplexml Fix the value param of SimpleXMLElement::addAttribute() 2021-12-22 12:35:59 +01:00
skeleton
snmp Fix bug #81598: Use C.UTF-8 as LC_CTYPE locale by default 2021-12-05 21:03:27 +01:00
soap Merge branch 'PHP-8.0' into PHP-8.1 2022-10-13 16:00:36 +02:00
sockets Merge branch 'PHP-8.0' into PHP-8.1 2022-10-01 11:23:34 +02:00
sodium Remove extra space before return type 2021-10-18 14:28:46 +02:00
spl Keep original EG(jit_trace_num) value around __autoload() 2022-09-29 15:00:52 +03:00
sqlite3 Merge branch 'PHP-8.0' into PHP-8.1 2022-07-27 13:06:15 +02:00
standard Fix GH-9905: constant() behaves inconsistent when class is undefined 2022-11-09 15:21:50 +01:00
sysvmsg
sysvsem
sysvshm Fix test wrt. deprecation of float to int conversions 2022-05-09 14:05:57 +02:00
tidy
tokenizer Add missing EXTENSION section to tests 2022-10-27 14:39:43 +01:00
xml
xmlreader Add missing EXTENSION section to tests 2022-10-27 14:39:43 +01:00
xmlwriter
xsl
zend_test Fix bad merge (b8dee9b3fc) 2022-06-20 18:46:17 +02:00
zip Merge branch 'PHP-8.0' into PHP-8.1 2022-06-15 15:39:00 +02:00
zlib Merge branch 'PHP-8.0' into PHP-8.1 2022-06-25 07:39:55 +01:00
ext_skel.php