From 47461368ca4ea2d2c23482cbd655bd96b2acbfc8 Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Mon, 19 Mar 2018 13:51:40 +0100 Subject: [PATCH] Fix #75944: Wrong cp1251 detection `\xFF` is a valid character of CP-1251. --- NEWS | 2 ++ ext/mbstring/libmbfl/filters/mbfilter_cp1251.c | 2 +- ext/mbstring/tests/bug75944.phpt | 13 +++++++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 ext/mbstring/tests/bug75944.phpt diff --git a/NEWS b/NEWS index 5a1d3b2f4b..921d9123d1 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,8 @@ PHP NEWS ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| ?? ??? ????, PHP 7.1.17 +- Mbstring: + . Fixed bug #75944 (Wrong cp1251 detection). (dmk001) 29 Mar 2018, PHP 7.1.16 diff --git a/ext/mbstring/libmbfl/filters/mbfilter_cp1251.c b/ext/mbstring/libmbfl/filters/mbfilter_cp1251.c index a26ce19492..2d47ac304a 100644 --- a/ext/mbstring/libmbfl/filters/mbfilter_cp1251.c +++ b/ext/mbstring/libmbfl/filters/mbfilter_cp1251.c @@ -142,7 +142,7 @@ mbfl_filt_conv_wchar_cp1251(int c, mbfl_convert_filter *filter) /* all of this is so ugly now! */ static int mbfl_filt_ident_cp1251(int c, mbfl_identify_filter *filter) { - if (c >= 0x80 && c < 0xff) + if (c >= 0x80 && c <= 0xff) filter->flag = 0; else filter->flag = 1; /* not it */ diff --git a/ext/mbstring/tests/bug75944.phpt b/ext/mbstring/tests/bug75944.phpt new file mode 100644 index 0000000000..81788d7196 --- /dev/null +++ b/ext/mbstring/tests/bug75944.phpt @@ -0,0 +1,13 @@ +--TEST-- +Bug #75944 (wrong detection cp1251 encoding because of missing last cyrillic letter) +--SKIPIF-- + +--FILE-- + +--EXPECT-- +string(12) "Windows-1251" +string(12) "Windows-1251" + -- 2.40.0