Skip to content

Commit 6fc8d01

Browse files
pakutomaalexdowad
authored andcommittedMar 24, 2023
Fix GH-10648: add check function pointer into mbfl_encoding
Previously, mbstring used the same logic for encoding validation as for encoding conversion. However, there are cases where we want to use different logic for validation and conversion. For example, if a string ends up with missing input required by the encoding, or if a character is input that is invalid as an encoding but can be converted, the conversion should succeed and the validation should fail. To achieve this, a function pointer mb_check_fn has been added to struct mbfl_encoding to implement the logic used for validation. Also, added implementation of validation logic for UTF-7, UTF7-IMAP, ISO-2022-JP and JIS.
1 parent a082696 commit 6fc8d01

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+1745
-114
lines changed
 

‎UPGRADING

+10
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,16 @@ PHP 8.2 UPGRADE NOTES
218218
dba_fetch(string|array $key, $skip, $dba): string|false
219219
is still accepted, but it is recommended to use the new standard variant.
220220

221+
- MBString
222+
. mb_check_encoding() now checks input encoding more strictly.
223+
. mb_detect_encoding() now checks input encoding more strictly
224+
when strict detection is enabled.
225+
. mb_convert_encoding() checks the input encoding more strictly
226+
if multiple encodings are passed to from_encoding
227+
and the mbstring.strict_detection INI directive is set to 1.
228+
This change only affects the encoding selection,
229+
not the result of the conversion.
230+
221231
- Random
222232
. random_bytes() and random_int() now throw \Random\RandomException on CSPRNG failure.
223233
Previously a plain \Exception was thrown.

‎ext/mbstring/libmbfl/filters/mbfilter_7bit.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ const mbfl_encoding mbfl_encoding_7bit = {
6464
&vtbl_7bit_wchar,
6565
&vtbl_wchar_7bit,
6666
mb_7bit_to_wchar,
67-
mb_wchar_to_7bit
67+
mb_wchar_to_7bit,
68+
NULL
6869
};
6970

7071
#define CK(statement) do { if ((statement) < 0) return (-1); } while (0)

0 commit comments

Comments
 (0)
Please sign in to comment.