[php-src] Issue #10192: PHP 8.2 and PHP 8.1 Bug

From: Date: Fri, 30 Dec 2022 16:43:06 +0000
Subject: [php-src] Issue #10192: PHP 8.2 and PHP 8.1 Bug
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-243292@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/10192 Author: unix-world ### Description The following code: ```php <?php ini_set('display_errors', '1'); // display runtime errors error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED); // error reporting date_default_timezone_set('UTC'); function detect_encoding($ystr, $csetlist='UTF-8, ISO-8859-1, ISO-8859-15, ISO-8859-2, ISO-8859-9, ISO-8859-3, ISO-8859-4, ISO-8859-5, ISO-8859-6, ISO-8859-7, ISO-8859-8, ISO-8859-10, ISO-8859-13, ISO-8859-14, ISO-8859-16, UTF-7, ASCII, SJIS, EUC-JP, JIS, ISO-2022-JP, EUC-CN, GB18030, ISO-2022-KR, KOI8-R, KOI8-U') { return @mb_detect_encoding((string)$ystr, (string)$csetlist, true); // mixed: (bool) FALSE or (string) 'CHARSET' } echo detect_encoding('A + B'); echo "\n"; echo detect_encoding('A - B'); ``` Resulted in this output ; On PHP 8.2 and 8.1, if the plus (+) character is present in a string will detect UTF-7 instead of UTF-8 as expected: ``` UTF-7 UTF-8 ``` But I expected this output instead ; on PHP 7.4 and PHP 8.0 works correctly. Output is this): ``` UTF-8 UTF-8 ``` I tested here with different PHP versions. Also tested in my computer with PHP 8.1.12 and 8.0.25 ### PHP Version 8.1 / 8.2 ### Operating System All

« previous php.bugs (#243292) next »