Bug #73251 [Ver->Nab]: [а-Ñ] range contains not all cyrillic letters, filtar_var() fails for valid st
| From: | cmb@php.net | Date: | Wed, 05 Oct 2016 11:49:09 +0000 |
| Subject: | Bug #73251 [Ver->Nab]: [а-Ñ] range contains not all cyrillic letters, filtar_var() fails for valid st | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-204473@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=73251&edit=1
ID: 73251
Updated by: cmb@php.net
Reported by: ikonta at yandex dot ru
Summary: [а-Ñ] range contains not all cyrillic letters,
filtar_var() fails for valid st
-Status: Verified
+Status: Not a bug
Type: Bug
-Package: Filter related
+Package: PCRE related
Operating System: Linux
PHP Version: 5.6.26
-Assigned To:
+Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
Actually, this is rather an issue with the Unicode layout. Ð
(U+0401) comes before Ð (U+0410), so it is rightly not considered
to be part of the range [Ð-Я].
Previous Comments:
------------------------------------------------------------------------
[2016-10-05 11:40:27] cmb@php.net
I can confirm the behavior which is, however, not particularly
related to ext/filter, but rather is a general issue of PCRE, see
<https://3v4l.org/oBqFi>.
Quite likely that is an issue of libpcre and not the PHP bindings,
though.
------------------------------------------------------------------------
[2016-10-05 11:01:05] ikonta at yandex dot ru
Description:
------------
Modern Russian alphabet contains 33 letters.
Standard UTF8 rage covers 32 of most common, but misses one ('Ñ').
Standard
U+0410 Ð
â¦
U+044F Ñ
Exceptions:
U+0401 Ð
U+0451 Ñ
http://www.utf8-chartable.de/unicode-utf8-table.pl?start=1024
[а-Ñ] range should include 'Ñ' (and [Ð-Я] â 'Ð') letter,
but actually do not.
Test script:
---------------
$ cat cyr_io.php
<?php
$str = "еÑе";
$valid_string_expr = '/(*UTF8)[^а-Ñ]/';
if (filter_var($str, FILTER_VALIDATE_REGEXP,
array("options"=>array("regexp"=>"$valid_string_expr"))) ===
FALSE)
echo ("string contains only cyrillic small letters\n");
else
echo ("string contains NOT only cyrillic small letters\n");
$str = "еÑÑ";
if (filter_var($str, FILTER_VALIDATE_REGEXP,
array("options"=>array("regexp"=>"$valid_string_expr"))) ===
FALSE)
echo ("string contains only cyrillic small letters\n");
else
echo ("string contains NOT only cyrillic small letters\n");
?>
Expected result:
----------------
$ php cyr_io.php
string contains only cyrillic small letters
string contains only cyrillic small letters
Actual result:
--------------
$ php cyr_io.php
string contains only cyrillic small letters
string contains NOT only cyrillic small letters
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=73251&edit=1