You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Test: grapheme_extract should slide properly past error bytes. (#17404)
grapheme_extract should slide properly past error bytes.
Adds a test to assert that the `$next` parameter of `grapheme_extract()`
points to the next byte offset in the input `$haystack` after accounting
for the moved offset, according to the docs:
> If offset does not point to the first byte of a UTF-8 character,
> the start position is moved to the next character boundary.
It seems that the existing behavior is to find the next grapheme
boundary from the original provided offset, but if the offset doesn’t
point to a valid starting byte, the assigned `$next` value will point
to the byte that was immediately decoded in the same call, leading to
possible infinite loops in user-space code.
```
while ( $at < strlen( $s ) ) {
$grapheme = grapheme_extract( "\x85PHP", 1, GRAPHEME_EXTR_COUNT, $at, $at );
// never moves past the second byte, always returns 'P'
}
```
0 commit comments