com php-src: Fixed bug #77025: NEWS ext/mbstring/libmbfl/mbfl/m bfilter_8bit.c ext/mbstring/tests/bug77025. phpt

From: Date: Wed, 17 Oct 2018 10:38:31 +0000
Subject: com php-src: Fixed bug #77025: NEWS ext/mbstring/libmbfl/mbfl/m bfilter_8bit.c ext/mbstring/tests/bug77025. phpt
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-103484@lists.php.net to get a copy of this message
Commit: 56665a1b17b8877164473872b90b68d5ac311306 Author: Nikita Popov <nikita.ppv@gmail.com> Wed, 17 Oct 2018 12:37:52 +0200 Parents: 2cc6462edc79b711930368173119d0bf045d8aa9 Branches: PHP-7.3 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=56665a1b17b8877164473872b90b68d5ac311306 Log: Fixed bug #77025 Implements 8bit conversions equivalently to iso-8859-1 conversions. This seems quite dubious to me, but seems to match the previous behavior. It might make more sense to map the characters into a private area instead, so that the 8bit encoding is treated as binary data with no case conversions (including no case conversions in the ascii range). Bugs: https://bugs.php.net/77025 Changed paths: M NEWS M ext/mbstring/libmbfl/mbfl/mbfilter_8bit.c A ext/mbstring/tests/bug77025.phpt Diff: diff --git a/NEWS b/NEWS index e029cda..6414007 100644 --- a/NEWS +++ b/NEWS @@ -11,6 +11,10 @@ PHP NEWS . Fixed bug #77007 (fractions in diff() are not correctly normalized). (Derick) +- Mbstring: + . Fixed bug #77025 (mb_strpos throws Unknown encoding or conversion error). + (Nikita) + - Tokenizer: . Fixed bug #76991 (Incorrect tokenization of multiple invalid flexible heredoc strings). (Nikita) diff --git a/ext/mbstring/libmbfl/mbfl/mbfilter_8bit.c b/ext/mbstring/libmbfl/mbfl/mbfilter_8bit.c index 4faa9b8..6b5b009 100644 --- a/ext/mbstring/libmbfl/mbfl/mbfilter_8bit.c +++ b/ext/mbstring/libmbfl/mbfl/mbfilter_8bit.c @@ -38,6 +38,11 @@ #include "mbfilter.h" +const struct mbfl_convert_vtbl vtbl_8bit_wchar; +const struct mbfl_convert_vtbl vtbl_wchar_8bit; +static int mbfl_filt_conv_8bit_wchar(int c, mbfl_convert_filter *filter); +static int mbfl_filt_conv_wchar_8bit(int c, mbfl_convert_filter *filter); + static const char *mbfl_encoding_8bit_aliases[] = {"binary", NULL}; const mbfl_encoding mbfl_encoding_8bit = { @@ -47,6 +52,42 @@ const mbfl_encoding mbfl_encoding_8bit = { (const char *(*)[])&mbfl_encoding_8bit_aliases, NULL, MBFL_ENCTYPE_SBCS, - NULL, - NULL + &vtbl_8bit_wchar, + &vtbl_wchar_8bit +}; + +const struct mbfl_convert_vtbl vtbl_8bit_wchar = { + mbfl_no_encoding_8bit, + mbfl_no_encoding_wchar, + mbfl_filt_conv_common_ctor, + mbfl_filt_conv_common_dtor, + mbfl_filt_conv_8bit_wchar, + mbfl_filt_conv_common_flush +}; + +const struct mbfl_convert_vtbl vtbl_wchar_8bit = { + mbfl_no_encoding_wchar, + mbfl_no_encoding_8bit, + mbfl_filt_conv_common_ctor, + mbfl_filt_conv_common_dtor, + mbfl_filt_conv_wchar_8bit, + mbfl_filt_conv_common_flush }; + +#define CK(statement) do { if ((statement) < 0) return (-1); } while (0) + +static int mbfl_filt_conv_8bit_wchar(int c, mbfl_convert_filter *filter) +{ + return (*filter->output_function)(c, filter->data); +} + +static int mbfl_filt_conv_wchar_8bit(int c, mbfl_convert_filter *filter) +{ + if (c >= 0 && c < 0x100) { + CK((*filter->output_function)(c, filter->data)); + } else { + CK(mbfl_filt_conv_illegal_output(c, filter)); + } + + return c; +} diff --git a/ext/mbstring/tests/bug77025.phpt b/ext/mbstring/tests/bug77025.phpt new file mode 100644 index 0000000..46416c1 --- /dev/null +++ b/ext/mbstring/tests/bug77025.phpt @@ -0,0 +1,12 @@ +--TEST-- +Bug #77025: mb_strpos throws Unknown encoding or conversion error +--FILE-- +<?php + +var_dump(mb_strpos('Hello', 'e', 0, '8bit')); +var_dump(mb_stripos('Hello', 'e', 0, '8bit')); + +?> +--EXPECT-- +int(1) +int(1)

« previous php.cvs (#103484) next »