[ticket/16708] Update the UTF-8 check for multiple encoding settings

Update the mbstring.http_input and mbstring.http_output configuration check, from being the deprecated PHP 5.6.x "PASS, or blank" to now be "UTF-8, or blank".  PHP documentation specifies this configuration should be left blank, in order to inherit default_charset, which phpBB requires to be configured as UTF-8.

For a phpBB customer where mbstring.http_input and mbstring.http_output is set to UTF-8 rather than being left blank, and is a shared hosting configuration that the customer isn't permitted to change, the phpBB ACP warning that "your http_input/http_output configuration is invalid" isn't helpful.

Their setting is UTF-8, which is the encoding http_input/http_output would be using if it had been left blank and allowed to inherit default_charset.  Our "warning" isn't advising the user of a misconfiguration which is causing a phpBB functionality problem.  phpBB is getting exactly the UTF-8 encoding it was intending to get; same as when it was checking whether the setting was left blank, too.

Also update the default_charset test to permit "UTF-8, or blank".  This had been correctly changed to effectively test "UTF-8, or NULL" during PHPBB3-16698, based on code inspection of /vendor/bantu/ini-get-wrapper/src/IniGetWrapper.php which confirmed IniGetWrapper::getString() will return NULL for any setting which does not exist.

However, testing on some PHP platforms shows PHP itself returning an empty string for a parameter which isn't defined in the PHP.INI, and so we receive an empty string instead of NULL.  So the test was updated so that we effectively check for "UTF-8, or blank, or NULL", all of which result in UTF-8 being used.

PHPBB3-16708
This commit is contained in:
EA117 2021-02-25 09:30:19 -06:00
parent bd1c3c87b7
commit 1276d2fdf3

View file

@ -702,9 +702,9 @@ class acp_main
'S_MBSTRING_LOADED' => true,
'S_MBSTRING_FUNC_OVERLOAD_FAIL' => $func_overload && ($func_overload & (MB_OVERLOAD_MAIL | MB_OVERLOAD_STRING)),
'S_MBSTRING_ENCODING_TRANSLATION_FAIL' => $encoding_translation && ($encoding_translation != 0),
'S_MBSTRING_HTTP_INPUT_FAIL' => !empty($http_input),
'S_MBSTRING_HTTP_OUTPUT_FAIL' => !empty($http_output),
'S_DEFAULT_CHARSET_FAIL' => $default_charset !== null && strtolower($default_charset) !== 'utf-8',
'S_MBSTRING_HTTP_INPUT_FAIL' => $http_input !== null && !in_array(strtolower($http_input), array('utf-8', '')),
'S_MBSTRING_HTTP_OUTPUT_FAIL' => $http_output !== null && !in_array(strtolower($http_output), array('utf-8', '')),
'S_DEFAULT_CHARSET_FAIL' => $default_charset !== null && !in_array(strtolower($default_charset), array('utf-8', '')),
]);
}