php / php-tasks

Tasks that need doing. This is for php-src maintainers. The end-user bug tracker is at https://bugs.php.net/.
27 stars 6 forks source link

Allow empty needle in grapheme_str*() functions #20

Closed kocsismate closed 4 years ago

kocsismate commented 4 years ago

Currently, string functions in ext/standard and ext/mbstring can accept an empty $needle, so we should add support for this in ext/intl as well.

The relevant code that needs to be changed is https://github.com/unicode-org/icu/blob/f744742e036441cbfd54b535e722dc3801ff0f63/icu4c/source/i18n/usearch.cpp#L2675. Discussion: https://github.com/php/php-src/pull/5972#discussion_r481912754

chschneider commented 4 years ago

I made a patch to allow empty needles by explicitly checking in grapheme_strpos_utf16.

See https://github.com/php/php-src/compare/master...chschneider:grapheme_empty_needles for the diff, should I submit a pull request or are there major issues with this approach?

nikic commented 4 years ago

@chschneider Looks reasonable