mirror of
https://github.com/php/php-src.git
synced 2024-09-22 02:17:32 +00:00
- Fixed bug #49354 (mb_strcut() cuts wrong length when offset is within a
multibyte character). (This bug was introduced by the commit by r202895. Please double-check the specification of the function you are going to *fix*.)
This commit is contained in:
parent
4b1c7c5615
commit
0c974164e2
@ -2665,10 +2665,6 @@ PHP_FUNCTION(mb_strcut)
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (((unsigned int)from + (unsigned int)len) > string.len) {
|
||||
len = string.len - from;
|
||||
}
|
||||
|
||||
ret = mbfl_strcut(&string, &result, from, len);
|
||||
if (ret == NULL) {
|
||||
RETURN_FALSE;
|
||||
|
21
ext/mbstring/tests/bug49354.phpt
Normal file
21
ext/mbstring/tests/bug49354.phpt
Normal file
@ -0,0 +1,21 @@
|
||||
--TEST--
|
||||
Bug #49354 (mb_strcut() cuts wrong length when offset is in the middle of a multibyte character)
|
||||
--SKIPIF--
|
||||
<?php extension_loaded('mbstring') or die('skip mbstring not available'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
$crap = 'AåBäCöDü';
|
||||
var_dump(mb_strcut($crap, 0, 100, 'UTF-8'));
|
||||
var_dump(mb_strcut($crap, 1, 100, 'UTF-8'));
|
||||
var_dump(mb_strcut($crap, 2, 100, 'UTF-8'));
|
||||
var_dump(mb_strcut($crap, 3, 100, 'UTF-8'));
|
||||
var_dump(mb_strcut($crap, 12, 100, 'UTF-8'));
|
||||
var_dump(mb_strcut($crap, 13, 100, 'UTF-8'));
|
||||
?>
|
||||
--EXPECT--
|
||||
string(12) "AåBäCöDü"
|
||||
string(11) "åBäCöDü"
|
||||
string(11) "åBäCöDü"
|
||||
string(9) "BäCöDü"
|
||||
string(0) ""
|
||||
bool(false)
|
Loading…
Reference in New Issue
Block a user