Bug #80360 [NEW]: Unicode character property \p{L} truncates match
| From: | benjamin dot morel at gmail dot com | Date: | Fri, 13 Nov 2020 13:34:37 +0000 |
| Subject: | Bug #80360 [NEW]: Unicode character property \p{L} truncates match | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-230324@lists.php.net to get a copy of this message | ||
From: benjamin dot morel at gmail dot com
Operating system: Ubuntu 18
PHP version: 7.4.12
Package: PCRE related
Bug Type: Bug
Bug description:Unicode character property \p{L} truncates match
Description:
------------
When using \p{L} on accented letters, the resulting match is truncated
and therefore invalid UTF-8.
Examples:
à = C3A0 is returned as C3
é = C3A9 is returned as C3
Test script:
---------------
$str = 'Voilà déjà ';
display($str);
preg_match_all('/\p{L}+/', $str, $matches);
foreach ($matches[0] as $match) {
display($match);
}
function display($str) {
echo bin2hex($str), ' ';
var_export(mb_check_encoding($str, 'UTF-8'));
echo PHP_EOL;
}
Expected result:
----------------
566f696cc3a02064c3a96ac3a0 true
566f696cc3a0 true
64c3a9 true
6ac3a0 true
Actual result:
--------------
566f696cc3a02064c3a96ac3a0 true
566f696cc3 false
64c3 false
6ac3 false
--
Edit bug report at https://bugs.php.net/bug.php?id=80360&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=80360&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=80360&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=80360&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=80360&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=80360&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=80360&r=support
Expected behavior: https://bugs.php.net/fix.php?id=80360&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=80360&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=80360&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=80360&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=80360&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=80360&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=80360&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=80360&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=80360&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=80360&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=80360&r=mysqlcfg