[13.x] Fix multibyte case-insensitive matching in Str::replace and Str::remove - #60882
Conversation
|
Agent review Blocking
Should Fix
Consider
|
Co-authored-by: Sebastian Hädrich <11225821+shaedrich@users.noreply.github.com>
316494e to
da659f2
Compare
|
Thanks for the thorough review, all addressed:
|
Co-authored-by: Sebastian Hädrich <11225821+shaedrich@users.noreply.github.com>
Str::replace()andStr::remove()with$caseSensitive = falsedelegateto
str_ireplace(), which only case-folds ASCII characters. Multibytecharacters are never matched case-insensitively:
This is inconsistent within the class itself ->
Str::contains()considersthe same strings a case-insensitive match:
ASCII-only search terms keep using
str_ireplace()exactly as before.Multibyte terms are matched via
preg_quote+/iupatterns with a callbackreplacement, replicating
str_ireplace()array pairing and sequentialsemantics. Subjects that are not valid UTF-8 fall back to
str_ireplace(),preserving the previous behavior.