1
0
mirror of https://github.com/php/php-src.git synced 2026-04-22 15:38:49 +02:00

Fix #75944: Wrong cp1251 detection

`\xFF` is a valid character of CP-1251.
This commit is contained in:
Christoph M. Becker
2018-03-19 13:51:40 +01:00
parent f46da1da7d
commit 47461368ca
3 changed files with 16 additions and 1 deletions
@@ -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 */
+13
View File
@@ -0,0 +1,13 @@
--TEST--
Bug #75944 (wrong detection cp1251 encoding because of missing last cyrillic letter)
--SKIPIF--
<?php extension_loaded('mbstring') or die('skip mbstring not available'); ?>
--FILE--
<?php
var_dump(mb_detect_encoding(chr(0xfe), array('CP-1251'))); // letter '?'
var_dump(mb_detect_encoding(chr(0xff), array('CP-1251'))); // letter '?'
?>
--EXPECT--
string(12) "Windows-1251"
string(12) "Windows-1251"